Multiple choice

Which one of the following will turn off buffering for stdout?

  1. setbuf(stdout, FALSE);

  2. setvbuf(stdout, NULL);

  3. setbuf(stdout, NULL);

  4. setvbuf(stdout, _IONBF);

  5. setbuf(stdout, _IONBF);

Reveal answer Fill a bubble to check yourself
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.