The End-of-File internal indicator of the stream is cleared after a call to this function, and all effects from previous calls to ungetc are dropped.
On streams open for update (read+write), a call to fsetpos allows to switch between reading and writing.
Parameters
- stream
- Pointer to a FILE object that identifies the stream.
- position
- Pointer to a fpos_t object containing a position previously obtained with fgetpos.
Return Value
If successful, the function returns a zero value.Otherwise, it returns a nonzero value and sets the global variable errno to a positive value, which can be interpreted with perror.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
After this code is successfully executed, a file called myfile.txt will contain:
This is a sample
See also
| fgetpos | Get current position in stream (function) |
| fseek | Reposition stream position indicator (function) |
| rewind | Set position indicator to the beginning (function) |
