TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Richard Hasty
from: Brad Benson
date: 1995-03-22 13:34:30
subject: Flush Buffers

PMFJI,

RH> AG> I want a solution which will not mean 50,000 edits to 12 source
RH> AG> files if possible. I did not write the app, and have no idea which
RH> AG> places in the code are potential problems. 
RH> 
RH> The problem is, os/2 doesn't flush the buffer until a newline char is
RH> sent. The only way around it is to call ffluch(stdout); after each
RH> prompt, unless you want to re-write printf to call fflush afterwards.

Actually, the 'problem' is in the C Set++ runtime library routines,
and may not be a problem at all.  I don't know if ANSI covers this
specific situation, but I've run across the same problem on many UNIX
machines as well.  There is a simple solution, though: turn off
buffering for stdout with the setvbuf() function, as in :

  char achBuf[2];
  setvbuf(stdout, achBuf, sizeof(achBuf), _IONBF);

...this will do what you want.  Note that the achBuf array is provided
for mostly portability; some runtime libraries will accept NULL and
some don't.  C Set++ doesn't as far as I know, and if you try then this
call will fail.

Cheers,
Brad


 þ KWQ/2 1.1 þ 

--- ProBoard v2.02b12 [Reg]
* Origin: Rivendell BBS - 612.323.9473 (1:282/90)
SEEN-BY: 105/42 620/243 624/50 711/401 409 410 413 430 807 808 809 934 955
SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809
@PATH: 282/90 30 1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.