In case you are trying this under Linux or another Unix-like system, it is the terminal that buffers the input and only passes an entire line. You can use ncurses to circumvent this:
#include
int main()
{
initscr();
getch();
endwin();
return 0;
}
Compile with:
gcc -o main main.c -lncurses