Mail Archives: djgpp/1997/10/08/08:46:18
At 02.06 1997-10-08 GMT, you wrote:
>I had some problem with printf and getch working together.
>Seems to me that the last printf preceeding a getch is executed only after
>a key is pressed.
>
>examples:
> printf ("\n1");
> printf ("\n2");
> printf ("\n3");
> getch ();
>would produce
>1
>2
>waiting for keystroke,
>after a key is pressed
>3
>
>Is this a know bug with djgpp? Is there any way to work around this?
>Thanks.
This is not a bug. This is because printf() (stdout) is buffered in DJGPP,
which means that it doesn't print the data until you flush it
(fflush(stdout);) or when a newline is found.
So either you put an fflush(stdout) in front of getch(), or you put the
newlines last in each string, or you use cprintf() instead.
This issue is covered in the FAQ too, look it up there!
-- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se --
*****************************************************
* A brief description of DJGPP: *
* NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! *
*****************************************************
- Raw text -