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/f/fgetpos.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/f/fgetpos.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/f/fgetpos.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/f/fgetpos.html on line 8

fgetpos()

Get the current position of a stream

Synopsis:

#include <stdio.h>

int fgetpos( FILE* fp, 
             fpos_t* pos );

Arguments:

fp
The stream whose position you want to determine.
pos
A pointer to a fpos_t object where the function can store the position.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The fgetpos() function stores the current position of the stream fp in the fpos_t object specified by pos.

You can use the value stored in pos in a call to fsetpos() if you want to reposition the file to the position at the time of the fgetpos() call.

Returns:

0 for success, or nonzero if an error occurs (errno is set).

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
    FILE *fp;
    fpos_t position;
    char buffer[80];

    fp = fopen( "file", "r" );
    if( fp != NULL ) {
        fgetpos( fp, &position ); /* get position     */
        fgets( buffer, 80, fp );      /* read record      */
        fsetpos( fp, &position ); /* set position     */
        fgets( buffer, 80, fp );      /* read same record */
        fclose( fp );
        
        return EXIT_SUCCESS;
    }
    
    return EXIT_FAILURE;
}

Classification:

ANSI, POSIX 1003.1

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

See also:

errno, fopen(), fseek(), fsetpos(), ftell()


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/f/fgetpos.html on line 152

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/f/fgetpos.html on line 152