Yes I know that whatever we are giving as a input that will be stored in the keyboard buffer [queue]. The getchar() will take characters from that queue.
we have to type a character and then press the Enter key for the first getchar() to accept a character. The first character input and Enter key will be stored in the keyboard buffer.
The getchar() function [ or any function to read a character ] will get characters from keyboard only when the keyboard buffer is free. In this case the, while reading the a character for the variable b the Enter key is stroed in the keyboard buffer and its not empty, so the b = getchar() functions takes the Enter key from the buffer and its not reading any characters from the keyboard.
My question is about clearing the keyboard buffer. If I remove the characters stroed in the buffer before reading a character for variable b then it will read a character from the keyboard.
Normally fflush(stdin) will do this, thus what I gave that statement before the b = getchar() function call, but the fflush function call is not removing the characters in the buffer. I don't know why ?.
so, My question is why the fflush(stdin) statement is not clearing the keyboard buffer[ I am getting this Unix/Linux only, the same is working in dos and windows].
Regards
Maniraja S