Mail Archives: djgpp/1997/07/05/18:17:31
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 |
---------------------------------------------------------------------
- Raw text -