TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: TONY CAPPELLINI 76370,2104
from: Scott t. Griepentrog 72427,335
date: 1990-06-14 12:10:02
subject: #4281-%#..$`## C Compiler

#: 4372 S3/Languages
    14-Jun-90  12:10:02
Sb: #4281-%#**$"## C Compiler
Fm: Scott t. Griepentrog 72427,335
To: TONY CAPPELLINI 76370,2104

Okay, your first problem is trying to use 'C Standard I/O' on OS9.  It will
work, but only if you are wanting line based input, not character based. This
is due to the way that TEXT versus BINARY paths are handled in OS9. A TEXT path
will be serviced via the I$READLN call, which gets one line, whereas the BINARY
paths (fread) will be serviced by I$READ call, which will get x chars.

There is a way to tell the C compiler to use BINARY mode on an input stream, so
that you can still use getchar() however:

Look on page 4-11 of the C compiler manual - getchar() page.

to set the stdin path for BINARY handling, do the line:

stdin->_flag|=_RBF;

BEFORE any input on stdin.

This way the C compiler will pull a I$READ instead of a I$READLN, and you will
get the char you wanted instead of a whole line at once.

However, I *highly* recommend that you do the following (low level i/o)
instead, as it will work a heck of a lot better:

read(0,&c,1);

Which reads stdin directly, into char c, one char.  That's the best way to get
just one byte from input.

Any more q's?

StG

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™.