TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: John Poltorak
from: Andrew Grillet
date: 1995-04-01 09:53:04
subject: scanf

JP> Saturday March 25 1995, Andrew Grillet writes to John Poltorak:

 JP>> values. Is this just a quirk of using an OS/2 compiler, or is Mr.
 JP>> Schildt in error here?

 AG> Arrh, Jim lad, 'tis a terrible thing, this C stuff....
 AG> You need to 'flush the buffer' to get the prompt stuff written. There
 AG> are two ways ...

 AG> call fflush() after writing the prompt stuff.

 JP> I am perfectly aware of the limitations of DOS, that's 
 JP> why I tried to get hold of a book which sounded 
 JP> 'platform indepedent'. I'm surprised that ICC works 
 JP> differently from GCC wrt SCANF, but I suppose it's part 
 JP> of the learning curve.

I think this could work differently under different file systems as well as
different compilers.The ANSI statement is that the buffers can be flushed
'when the system feels like it' or when you tell it to. 

While most systems figure out that its a good idea to flush on CR/LF,
flusshing without the user asking for it is really not so clever in 
a multi-thread environment. It will use extra CPU power that isn't needed. 

Under Un*x, my experience is that if you don't use setvbuf() or something 
similar, then you will have to cal ffflush() sometimes! GCC is probably 
configurable, but I've never used it except on Un*x. I normally put in
fflush() 'just in case'. My problem was in porting code written by someone
else for a different compiler.

Andrew


--- Maximus/2 2.01wb
* Origin: Me/2 (2:254/259)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 254/259 1 255/1 440/4 141/209 270/101 105/103 42 712/515 711/808 809
@PATH: 711/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™.