flush.c
/**
* flush.c
*
* Demonstrates flushing the stdout buffer in C
*
* Compile: gcc -g -Wall -o flush flush.c
* Run: ./flush
*
* To measure performance, run with the time command:
* time ./flush
*/
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 1000000; ++i) {
printf("%d ", i);
/* We'll flush the output here. This ensures that everything has been
* printed to the terminal before continuing -- useful for debugging. */
fflush(stdout);
}
return 0;
}