TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: TONY CAPPELLINI 76370,2104 (X)
from: Bruce MacKenzie 71725,376
date: 1990-06-12 19:44:26
subject: #4281-%#..$`## C Compiler

#: 4323 S3/Languages
    12-Jun-90  19:44:26
Sb: #4281-%#**$"## C Compiler
Fm: Bruce MacKenzie 71725,376
To: TONY CAPPELLINI 76370,2104 (X)

Tony,
     First, fflush() only works for output buffers, it does nothing to an input
buffer.  Assuming stdin is buffer, during your first getchar() call the object
code does a readln system call which reads characters from the keyboard up to
and including a CR.  So you press a key and hit [ENTER]. Both the keypress and
a CR are placed in the C buffer, and the keypress is read out by the getchar().
The second time through, the getchar() call reads the CR from the first call
rather than going back to the keyboard with a second readln--not what you want
at all.  The quick and dirty solution is to always do a second getchar to clear
the CR after reading a keypress in this manner.

SOURCE: compuserve via textfiles.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™.