Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rewind.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rewind.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rewind.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rewind.html on line 8

rewind()

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:

ANSI, POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

clearerr(), fopen(), fseek()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rewind.html on line 162

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rewind.html on line 162