Mail Archives: djgpp/1997/02/04/01:47:34
On 3 Feb 1997, Douglas Gleichman wrote:
> > This doesn't always work because DOS sometimes uses its own buffers for
> > stdout.
>
> When? I've never seen this.
When stdout is redirected to a file or a pipe.
> > fflush() or a newline always works, though.
>
> Turbo C/ Microsoft C have buffering turned off by default. DJGPP has
> it on. The above call to setbuf will make DJGPP operate like those
> other compilers.
But it makes screen I/O much slower, because a mode switch (protected
mode to real mode and back) is required for *each character* when your
stream is unbuffered. That's a lot of overhead if your program has a lot
to print.
Another ``easy'' solution would be to #define printf cprintf at the top
of the source code.
> If you are porting a program over to DJGPP it seems
> that it would be a lot easier to add one line than to search for every
> printf and add a fflush after it.
If you indeed care for portability, you should use `fflush' even in Turbo
C. If you don't care for portability, then you are amply punished (IMHO).
- Raw text -