Which one of the following will turn off buffering for stdout?
-
setbuf(stdout, FALSE);
-
setvbuf(stdout, NULL);
-
setbuf(stdout, NULL);
-
setvbuf(stdout, _IONBF);
-
setbuf(stdout, _IONBF);
C
Correct answer
Explanation
setbuf(stdout, NULL) turns off buffering by setting the buffer to NULL. This causes unbuffered output. setvbuf requires specifying buffer size and mode. _IONBF is a mode constant for setvbuf, not a buffer pointer. FALSE is not valid for setbuf.