Definition | #include <stdio.h> int fgetc(FILE *fp);
| ||
Return val. | integer | If successful, the character as a positive integer value. | |
EOF | for end of file or error. | ||
Notes |
in your program, the variable c must always be declared as an integer. If you define c as a If The following applies in the case of text files with SAM access mode and variable record length for which a maximum record length is also specified: When the specification For text files with access mode SAM or ISAM, | ||
Example | The following program successively reads one character at a time from a maximum of 10 files passed in the call and outputs the character on the standard output. #include <stdio.h>
FILE *fp[10], **app;
int main(int argc, char *argv[])
{
int c, i;
for (i = 1; i < argc && i <= 10; i++)
fp[i-1] = fopen(argv[i], "r");
app = fp;
while(*app != NULL)
{
c = fgetc(*app++);
putchar(c);
}
putchar('\n');
return 0;
}
| ||
See also | getc, getchar, ungetc, fopen, fopen64, _fnlinserted | ||