rewind


rewind

Resets a file's access position to the beginning of the file

 #include <stdio.h> void rewind ( FILE *fp  ); 

The rewind( ) function sets the access position of the file associated with the FILE pointer fp to the beginning of the file, and clears the EOF and error flags.

Example

This example prints the contents of a file twice, converting each character to lowercase the first time through, and to uppercase the second time:

 FILE *fp; int c; if (( fp = fopen( argv[1], "r" )) == NULL )   fprintf( stderr, "Failed to open file %s\n", argv[1] ); else {   puts( "Contents of the file in lower case:" );   while (( c = fgetc( fp )) != EOF )     putchar( tolower( c ));   rewind( fp );   puts( "Same again in upper case:" );   while (( c = fgetc( fp )) != EOF )     putchar( toupper( c ));   fclose( fp ); } 

See Also

fseek( ), ftell( ), fgetpos( ), fsetpos( ), clearerr( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net