Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdio.h>
    long int ftell( FILE *fp );

Description:
    The ftell function returns the current read/write position of the file
    specified by fp.  This position defines the character that will be read
    or written by the next I/O operation on the file.  The value returned by
    ftell can be used in a subsequent call to  fseek to set the file to the
    same position.

Returns:
    The ftell function returns the current read/write position of the file
    specified by fp.  When an error is detected, -1L is returned.  When an
    error has occurred,  errno contains a value indicating the type of error
    that has been detected.

Example:
    #include <stdio.h>

    long int filesize( FILE *fp )
      {
        long int save_pos, size_of_file;

        save_pos = ftell( fp );
        fseek( fp, 0L, SEEK_END );
        size_of_file = ftell( fp );
        fseek( fp, save_pos, SEEK_SET );
        return( size_of_file );
      }

    void main()
      {
        FILE *fp;

        fp = fopen( "file", "r" );
        if( fp != NULL ) {
          printf( "File size=%ld\n", filesize( fp ) );
          fclose( fp );
        }
      }

Classification:
    ANSI

Systems:
    All, Netware

See Also:
    fgetpos, fopen, fsetpos, fseek

See Also: fgetpos fsetpos

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson