//* Demonstrating need for fflush *

// The results are compiler dependent because some compilers include // IO libraries that have buffers for sake of better performance // while others do not cache stdin and stdout at all #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <unistd.h> int main() { int i; printf("\n\nTest2:\n\n"); printf("A loop without fflush:\n"); for (i=0; i<78; i++) { printf("."); sleep(1); } printf("\n"); printf("A loop with fflush:\n"); for (i=0; i<78; i++) { printf("."); fflush(stdout); sleep(1); } printf("\n"); return(0); } // This demo did not work for me on recent Visual Studio Compilers - DrAM