Question: For the sake of education, and programming practice, I'd like to write a simple library that can handle raw keyboard input, and output to the terminal in 'real time'.

I'd like to stick with ansi C as much as possible, I just have no idea where to start something like this. I've done several google searches, and 99% of the results use libraries, or are for C++.

I'd really like to get it working in windows, then port it to OSX when I have the time.

Answer: 
To set an open stream to be non-buffered using ANSI C, you can do this:

```
#include <stdio.h>
if (setvbuf(fd, NULL, _IONBF, 0) == 0)
  printf("Set stream to unbuffered mode\n");

```

(Reference: C89 4.9.5.6)

However, after that you're on your own. :-)
This is not possible using only standard ISO C. However, you can try using the following:

```
#include <stdio.h>
void setbuf(FILE * restrict stream, char * restrict buf); 

```

and related functions.

Your best bet though is to use the `ncurses` library.