rewind
raw OCR
Repositions a file pointer to the beginning of a stream.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
void rewind(FILE *stream);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
rewi'indistream) is equivalent to iseek{stream, OL, SEEK_SET), except that rewind clears the end-of-file and error indicators, while fseek only clears the end-of-file indicator.
After rewind, the next operation on an update file can be either input or output.
Return value
None.
See also
Example
See fseek
#include <stdio.h>
#include <dir.h>
int main (void)
{
FILE *fp;
char *fname = "TXXXXXX", *newnaine, first;
newname - mktemp(fname);
fp = fopen(newname,"w+");
fprintf (fp,"abcdefghijklmnopqrstuvwxyz") ;
rewind (fp);
fscanf (fp,"%c",&first) ;
printfC'The first character is: %c\n",first);
fclose(fp) ;
remove (newname);
return 0;
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/rewind/
· short form /3.1/rewind/