This documentation is archived and is not being maintained.

_tell, _telli64

Get the position of the file pointer.

long _tell(
   int fd 
__int64 _telli64(
   int handle 


File descriptor referring to open file.

Return Value

A return value of –1L indicates an error, and errno is set to EBADF to indicate an invalid file descriptor argument. On devices incapable of seeking, the return value is undefined.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on this, and other, return codes.


The _tell function gets the current position of the file pointer (if any) associated with the fd argument. The position is expressed as the number of bytes from the beginning of the file. For the _telli64 function, this value is expressed as a 64-bit integer.


Routine Required header Compatibility
_tell <io.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_telli64 <io.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_tell.c
/* This program uses _tell to tell the
 * file pointer position after a file read.

#include <io.h>
#include <stdio.h>
#include <fcntl.h>

int main( void )
   int  fh;
   char buffer[500];

   if( (fh = _open( "crt_tell.txt", _O_RDONLY )) != -1 )
      if( _read( fh, buffer, 500 ) > 0 )
         printf( "Current file position is: %d\n", _tell( fh ) );
      _close( fh );

Input: crt_tell.txt

Line one.
Line two.


Current file position is: 20

See Also

Low-level I/O Routines | ftell | _lseek | Run-Time Routines and .NET Framework Equivalents