void rewind ( FILE * stream );
Set position of stream to the beginning
Sets the position indicator associated with stream to the beginning of the file.
The end-of-file and error internal indicators associated to the stream are cleared after a successful call to this function, and all effects from previous calls to ungetc on this stream are dropped.
On streams open for update (read+write), a call to rewind allows to switch between reading and writing.
- Pointer to a FILE object that identifies the stream.
/* rewind example */
int main ()
FILE * pFile;
char buffer ;
pFile = fopen ("myfile.txt","w+");
for ( n='A' ; n<='Z' ; n++)
fputc ( n, pFile);
A file called myfile.txt is created for reading and writing and filled with the alphabet. The file is then rewinded, read and its content is stored in a buffer, that then is written to the standard output:
- Reposition stream position indicator (function
- Set position indicator of stream (function
- Flush stream (function