FGETC(DOS) XENIX System V FGETC(DOS)
Name
fgetc, fgetchar - Gets a character from a stream.
Syntax
#include <stdio.h>
int fgetc (stream);
FILE *stream;
int fgetchar ( );
Description
The fgetc function reads a single character from the input
stream at the current position and increments the associated
file pointer (if any) to point to the next character.
fgetchar is equivalent to fgetc(stdin).
Return Value
fgetc and fgetchar return the character read. A return
value of EOF may indicate an error or end-of-file; however,
the EOF value is also a legitimate integer value, so feof or
ferror should be used to verify an error or end-of-file
condition.
See Also
putc(S), fputchar(DOS), getc(S)
Example
#include <stdio.h>
FILE *stream; char buffer[81]; int i; int ch;
.
.
. /* The following statements gather a line of input from
** a stream. */
for (i = 0; (i < 80) && ((ch = fgetc (stream)) != EOF) &&
(ch != '\n'); i++) buffer[i] = ch;
buffer[i] = '\0';
/* "fgetchar ( )" could be used instead of "fgetc (stream)"
in ** the for statement above to gather a line of input from
** stdin (equivalent to "fgetc (stdin)"). */
Notes
fgetc and fgetchar are identical to getc and getchar, but
are functions, not macros.
These calls must be compiled with the -dos flag.
Page 1 (printed 8/7/87)