Question on printf()
Conor P. Cahill
cpcahil at virtech.uucp
Fri Jun 15 22:00:03 AEST 1990
In article <1990Jun15.042610.18292 at dasys1.uucp> jpr at dasys1.UUCP (Jean-Pierre Radley) writes:
>In article <1990Jun8.030206.4532 at virtech.uucp> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>> [as one of the ways to geta printf() call to show up right away]
>
>>3. add a setbuf(stdout,(char *) 0) at the begining of your program. This
>>turns off all output buffering and can have a detrimental effect on the
>>overall performance of your software.
>
>Why is that?
Because it causes all output be be written immediatly. If you are using
something like curses for a full screen program it noticably slows down
the screen drawing. (Enough that an end-user will notice and complain about
it).
Normally output is not written to stdout (that is associated with a tty) until
a newline is sent. When stdout is redirected to a file, it is buffered for
a full stdio block. Using setbuf() turns off all buffering.
--
Conor P. Cahill (703)430-9247 Virtual Technologies, Inc.,
uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160
Sterling, VA 22170
More information about the Comp.unix.questions
mailing list