Message-Id: <3.0.16.19971008144349.2967d076@hem1.passagen.se> Date: Wed, 08 Oct 1997 14:43:51 -0400 To: djgpp AT delorie DOT com From: Peter Palotas Subject: Re: Why don't printf work properly with getch ()? Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk 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! * *****************************************************