{{keywords>wiki library source code example reference}} ===== rewind ===== void rewind(FILE *stream); equal like fseek(stream, 0L, SEEK_SET); clearerr(stream); Resets the read pointer to the beginning of the File and clear the error indicator ===== C Sourcecode Example ===== /* * rewind example code * http://code-reference.com/c/stdio.h/rewind */ #include /* including standard library */ //#include /* uncomment this for Windows */ int main (void) { FILE *stream; int c; long seek_position; seek_position = 21; stream=fopen("test.txt", "r" ); if (stream == 0) { perror("cannot open file"); return 0; } while( (c=getc(stream)) != EOF) { putc(c, stdout); } /* Set Position with rewind to the beginning of the file */ rewind(stream); /* SET SEEK CUR to 20 char of the file */ fseek(stream, seek_position, SEEK_CUR ); while( (c=getc(stream)) != EOF) { putc(c, stdout); } return 0; } === content of test.txt === Test example file for code-reference.com rewind source code ==== output ==== output: ./rewind Test example file for code-reference.com rewind source code code-reference.com rewind source code see also [[c:stdio.h:fseek|]]