For binary streams, the value returned corresponds to the number of bytes from the beginning of the file.
For text streams, the value is not guaranteed to be the exact number of bytes from the beginning of the file, but the value returned can still be used to restore the position indicator to this position using fseek.
Parameters
- stream
- Pointer to a FILE object that identifies the stream.
Return Value
On success, the current value of the position indicator is returned.If an error occurs, -1L is returned, and the global variable errno is set to a positive value. This value can be interpreted by perror.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
This program prints out the size of myfile.txt in bytes.
See also
| fseek | Reposition stream position indicator (function) |
| fgetpos | Get current position in stream (function) |
| rewind | Set position indicator to the beginning (function) |
