fgetc and getc are equivalent, except that the latter one may be implemented as a macro.
Parameters
- stream
- Pointer to a FILE object that identifies the stream on which the operation is to be performed.
Return Value
The character read is returned as an int value.If the End-of-File is reached or a reading error happens, the function returns EOF and the corresponding error or eof indicator is set. You can use either ferror or feof to determine whether an error happened or the End-Of-File was reached.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
This program reads an existing file called myfile.txt character by character and uses the n variable to count how many dollar characters ($) does the file contain.
See also
| getc | Get character from stream (function) |
| fputc | Write character to stream (function) |
| fread | Read block of data from stream (function) |
| fscanf | Read formatted data from stream (function) |
