I have this code
while(1){
printf("hello world !\n");
fgetc(stdin);
}
when this runs and I enter a letter like this:
hello world !
a
it ignores the fgetc(stdin) in the next loop and prints hello world twice without waiting for input.
hello world !
a
hello world !
hello world !
a
hello world !
hello world !
a
hello world !
hello world !
a
hello world !
hello world !
I have tried putting fflush(stdin) before or after the fgetc(stdin) but it still produces the same behaviour, what am I doing wrong ?