fgetc
raw OCR
Gets character from stream.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
int fgetc(FILE *stream);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
fgetc returns the next character on the named input stream.
Return value
On success, fgetc returns the character read, after converting it to an int without sign extension. On end-of-file or error, it returns EOF.
See also
Example
#include <string.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
FILE *stream;
char string[] - "This is a test", ch;
/* open a file for update */
stream = fopen ("DUMMY.FIL", "w+");
/* write a string into the file */
fwrite(string, strlen(string) , 1, stream);
/* seek to the beginning of the file */
fseek(stream, 0, SEEK_SET);
do {
ch = fgetc (stream); /* read a char from the file */
putch(ch); /* display the character */
}
while (ch != EOF);
fclose(stream);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/fgetc/
· short form /3.1/fgetc/