From: "A.Appleyard" To: djgpp AT sun DOT soe DOT clarkson DOT edu Date: Mon, 27 Feb 1995 08:14:53 GMT Subject: Re: Question reagarding kbhit() jkeene AT unlinfo DOT unl DOT edu (Jon Keene) wrote (Subject: Question regarding kbhit()):- > Could anyone tell me why it is that when I run the following program, it > pauses for the keyboard hit _before_ doing any output? #include #include #define BUFSIZE 1840 /* (80 * 23) */ #define BLANK ' ' main () {int i, buf[BUFSIZE]; for ( i = 0; i < BUFSIZE; i++ ) buf[i] = BLANK; buf[0] = 'a'; buf[BUFSIZE - 1] = 'z'; for ( i = 0; i < BUFSIZE; i++ ) printf("%c", buf[i]); while (!kbhit()) ; return 0;} printf() (formatted print to screen) stores the output characters in a buffer and only sends the bufferful to the screen when it is told to print a '\n'. `fflush(stdout);' called after each fprint() call will empty FILE* stdout's buffer and thus cause the behavior that you seem to want.