Definition | #include <stdio.h> void rewind(FILE *fp);
|
Notes | The calls System files (SYSDTA, SYSOUT, SYSLST) cannot be positioned. If new records are written to a text file (opened for creation or in append mode) and a If the |
Record I/O |
|
Example | The following program first processes a file from the 11th character onwards to the end of the file and then continues at the beginning of the file (only works with binary files, i.e. in this case only with SAM and PAM files). #include <stdio.h> int main(void) { FILE *fp; int c,i; fp = fopen("input","rb"); /* skip the first 10 characters */ fseek(fp,10L,SEEK_SET); while((c=getc(fp)) != EOF) putc((char)c,stdout); /* position to the beginning of the file */ rewind(fp); for(i=0; i<10; i++) { c=getc(fp); putc((char)c,stdout); } fclose(fp); return 0; } |
See also | fseek, fseek64, fsetpos, fsetpos64 |