Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

_tell, _telli64 

Get the position of the file pointer.

long _tell(
   int handle
__int64 _telli64(
   int handle 



File descriptor referring to open file.

The current position of the file pointer. On devices incapable of seeking, the return value is undefined.

A return value of –1L indicates an error. If handle is an invalid file descriptor, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions set errno to EBADF and return -1L.

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 handle 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, _telli64


Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For additional compatibility information, see Compatibility in the Introduction.

// 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>
#include <share.h>
#include <string.h>

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

   if ( _sopen_s( &fh, "crt_tell.txt", _O_RDONLY, _SH_DENYNO, 0) )
      char buff[50];
      _strerror_s( buff, sizeof(buff), NULL );
      printf( buff );
      exit( -1 );

   if( _read( fh, buffer, 500 ) > 0 )
      printf( "Current file position is: %d\n", _tell( fh ) );
   _close( fh );

Line one.
Line two.


Current file position is: 20

Community Additions

© 2015 Microsoft