_tell, _telli64

Get the position of the file pointer.

long_tell(inthandle**);**

__int64_telli64(inthandle**);**

Routine Required Header Compatibility
_tell <io.h> Win 95, Win NT
_telli64 <io.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

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

Parameter

handle

Handle referring to open file

Remarks

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.

Example

/* 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>

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

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

Output

Current file position is: 434

Low-level I/O Routines

See Also   ftell, _lseek