fgetc() - I/O Function
How is "fgetc()" used in C++?
is an I/O function that returns the next character of the input stream, then increments the file position indicator. The value is read as an unsigned char after which it is converted to an integer. If the EOF is reached or an error occurs the function returns EOF and the eof indicator is set. This function may mark the st_atime field of the file associated with stream for update.
int fgetc ( FILE * stream );
FILE *stri = fopen("getceg.txt", "r");
while (c != EOF)
c = fgetc (stri);
if (c == 'A') count++;
printf ("The file contains A %d times.\n",count);
The file contains A 3 times
In the above example the "fgetc()" is used to check how many times the character 'A' is present in the