| Summary | |
#include <stdio.h>
int fgetc (
FILE *stream); /* stream to read from */
|
| Description | | The fgetc function reads a single character from stream and updates the file pointer to point to the next character. The fgetc function is in the RL-FlashFS library. The prototype is defined in stdio.h. |
| Return Value | | The fgetc function returns the character read as an int type. An EOF is returned for error or end-of-file conditions. Use the feof or ferror functions to distinguish an error from end-of-file. |
| See Also | | feof, ferror, fgets, fputc, ungetc |
| Example | |
#include <rtl.h>
#include <stdio.h>
void tst_fgetc (void) {
FILE *fin;
int ch;
fin = fopen ("Test.txt","r");
if (fin == NULL) {
printf ("File not found!\n");
}
else {
// dump the text file to a screen
while ((ch = fgetc (fin)) != EOF) {
putchar (ch);
}
fclose (fin);
}
}
|