Disable output buffering on stdout in c

Like other languages output buffering takes place even in C. Output buffering will cause output of a program to appear in chunks after long intervals, instead of each line appearing the moment it is output. To disable output buffering a very strange piece of code has to be written which looks like this

//disable output buffering
setvbuf(stdout, NULL, _IONBF, 0);

printf('Hello');

Or call the fflush after every output

printf('hello');
fflush(stdout);

The above is for Linux.







Last Updated On : 28th March 2013

Subscribe to get updates delivered to your inbox

Leave a comment