Sun Studio 12: Fortran Library Reference

1.4.13.2 ftell: Return Current Position of File

The function is called by:

INTEGER*4 ftell

n = ftell( lunit )

lunit

INTEGER*4

Input 

Open logical unit 

Return value 

INTEGER*4

Output 

n>=0: n=Offset in bytes from start of file

n<0: n=System error code

Example: ftell():


       INTEGER*4 ftell, lunit/1/, n
       open( UNIT=lunit, FILE=’MyFile’ )
       ...
       n = ftell( lunit )
       if ( n .lt. 0 ) stop ’ftell error’
       ...

Example: Same example in a 64-bit environment and compiled with -m64:


       INTEGER*4 lunit/1/
       INTEGER*8 ftell, n
       open( UNIT=lunit, FILE=’MyFile’ )
       ...
       n = ftell( lunit )
       if ( n .lt. 0 ) stop ’ftell error’
       ...

See also fseek(3S) and perror(3F); also fseeko64(3F) ftello64(3F).