GETCHAR/GETC - read a character.

Alternate Entry Name: GET.CH

Usage:

B:
   char_got = getchar( );
   char_got = getc( unit );
/* C users use C "fgetc", "getchar", etc. */

Where:

unit
is any valid I/O unit number (allowed only for GETC).

Description:

GETCHAR gets a character from the current read unit and returns it to the caller. The current read unit must be open as a character stream input unit; otherwise, the end-of-file character ('*e') is returned.

With GETC, you must specify a unit. GETC switches to the designated unit, calls GETCHAR to get the character, then restores the original read unit and returns with the character which was read.

If the "unit" passed to GETC is not open for reading, an end-of-file character ('*0') is returned. (Note that the C version of "getchar" returns a -1 to indicate end-of-file instead of zero.)

Notes:

Because '*0' indicates end-of-file, GETCHAR ignores and skips ASCII null characters in Media 6 files. However, GETCHAR returns null characters in Media 4 input. To determine whether a return of '*0' indicates end-of-file or just an ASCII null, call EOF to check for end-of-file. You could also specify the "zc" option when you OPEN the file, in which case end-of-file is indicated by -1 rather than zero.

See Also:

expl b lib open

expl b lib eof

Copyright © 1996, Thinkage Ltd.