Code:
#include <stdio.h>
int main() {
setvbuf(stdin, NULL, _IONBF, 0);
int input;
input = getchar();
printf("\n%c", input);
return 0;
}
The setvbuf statement is supposed to disable the buffering for the stdin stream.
And getchar reads 1 character from the stdin.
So I expected this program to reach the printf statement as soon as I enter a character in the console.
But that does not happen. The program pauses at getchar and waits for it to read until I press the return_key. As though stdin is line buffered.
Why does that happen? Am I not allowed to change how the stdin is buffered?