From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: printf question Date: Sat, 05 Jul 1997 15:49:48 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 29 Message-ID: <33BE6D1C.7477@cs.com> References: <5plnp1$h0g$1 AT news DOT sas DOT ab DOT ca> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp103.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk kalyniuk AT freenet DOT edmonton DOT ab DOT ca wrote: > > Can anyone explain to me why printf() wont immediately print to the screen > after calling clrscr(), unless I use fflush(stdout) first? It works fine > without the fflush() on my Borland compiler. In DJGPP, stdout is line-buffered. This is correct ANSI behavior, and it's necessary because in protected mode the overhead of a mode switch to print text is relatively high. To overcome the buffering, you can do one of the following: - Print a newline character - Call fflush( stdout ) - Use a stdio input function such as scanf() or gets() - Turn off the stdout buffering using setvbuf(). BTW, you should always be careful when mixing conio and stdio functions. stdio uses the standard DOS file system to read and write data, while conio writes directly to the screen and reads directly from the BIOS keyboard interrupt. -- --------------------------------------------------------------------- | John M. Aldrich | "Sin lies only in hurting other | | aka Fighteer I | people unnecessarily. All other | | mailto:fighteer AT cs DOT com | 'sins' are invented nonsense." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------