Hi,
I found this simple code
Code:
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
int main ( void )
{
int yn = 'y';
while ( tolower ( yn ) == 'y' ) {
printf ( "Doing stuff\n" );
printf ( "Do more stuff? (y/n): " );
fflush ( stdout );/* this line */
yn = getch();
printf ( "\n" );
}
return 0;
}
What I noticed is fflush function call On an output stream, fflush causes any buffered but unwritten data to be written;
I cannot figure out why fflush (stdout) is called here in this code
I try to comment this line and behavior was exactly the same.
Can someone explain what is purpose of calling fflush (stdout) for output stream here and general?