rewind()
QNX SDP8.0C Library ReferenceAPIDeveloper
Rewind a file stream to the beginning of the file
Synopsis:
#include <stdio.h>
void rewind( FILE *fp );
Arguments:
- fp
- The file stream that you want to rewind.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The rewind() function rewinds the file stream specified by fp to the beginning of the file. It's equivalent to calling fseek() like this:
fseek( fp, 0L, SEEK_SET );
except that the error indicator for the stream is cleared.
Examples:
This example shows how you might implement a two-pass assembler:
#include <stdio.h>
#include <stdlib.h>
void assemble_pass( FILE *fp, int passno )
{
printf( "Pass %d\n", passno );
/* Do more work on the fp */
switch( passno ) {
case 1:
/* do the first-pass work */
break;
case 2:
/* do the second-pass work */
break;
default:
break;
}
}
int main( void )
{
FILE *fp;
fp = fopen( "program.s", "r" );
if( fp != NULL ) {
assemble_pass( fp, 1 );
rewind( fp );
assemble_pass( fp, 2 );
fclose( fp );
return EXIT_SUCCESS;
}
puts( "Error opening program.s" );
return EXIT_FAILURE;
}
Classification:
Safety: | |
---|---|
Cancellation point | Yes |
Signal handler | No |
Thread | Yes |
Page updated: