Hi,
I found this simple code
What I noticed is fflush function call On an output stream, fflush causes any buffered but unwritten data to be written;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; }
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?



1Likes
LinkBack URL
About LinkBacks


