Mail Archives: djgpp/1997/08/17/03:57:57
Robert Debeljakovic wrote:
>
> Hi all,
> I just started writing some test programs and I came across something...
> If you use printf without a newline character in the string, it does print the
> test to the screen....
>
> eg:
> printf("hello\n"); gives me
> hello
>
> where as printf("hello"); gives me
> [nothing]
This is one of the more commonly asked DJGPP questions. :) By default,
standard output in DJGPP is line-buffered. The buffer is flushed when
any of the following occur:
- You print a newline character ('\n').
- You flush the stdout buffer with fflush().
- You call an input function which reads from stdin: getchar(),
scanf(), gets(), etc.
- You overflow the internal stdout buffer.
- You disable buffering with a call to setbuf() or setvbuf().
One other bit of information: it is a bad idea to mix stdio functions
with conio functions when requesting input from users. While stdout is
buffered and goes through the DOS file handling functions, conio writes
directly to video memory and reads directly from the BIOS keyboard
interrupt. If you do plan to use conio to get input (single or extended
keystrokes, for instance), you should either use conio output functions
or make sure to flush the buffer before reading input or clearing the
screen.
hth!
--
---------------------------------------------------------------------
| John M. Aldrich |"A competent and self-confident person|
| aka Fighteer I | is incapable of jealousy in anything.|
| mailto:fighteer AT cs DOT com | Jealousy is invariably a symptom of |
| http://www.cs.com/fighteer | neurotic insecurity." - Lazarus Long|
---------------------------------------------------------------------
- Raw text -