Skip to content

Latest commit

 

History

History
105 lines (78 loc) · 2.88 KB

tell-telli64.md

File metadata and controls

105 lines (78 loc) · 2.88 KB
description title ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords ms.assetid
Learn more about: _tell, _telli64
_tell, _telli64
4/2/2020
_telli64
_tell
_o__tell
_o__telli64
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-stdio-l1-1-0.dll
DLLExport
apiref
CORECRT_IO/_tell
CORECRT_IO/_telli64
_tell
_telli64
tell function
file pointers [C++], getting
_tell function
file pointers [C++]
telli64 function
_telli64 function
1500e8f9-8fec-4253-9eec-ec66125dfc9b

_tell, _telli64

Get the position of the file pointer.

Syntax

long _tell(
   int handle
);
__int64 _telli64(
   int handle
);

Parameters

handle
File descriptor referring to open file.

Return value

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.

For more information about return codes, see errno, _doserrno, _sys_errlist, and _sys_nerr.

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.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Routine Required header
_tell, _telli64 <io.h>

For more compatibility information, see Compatibility.

Example

// 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 );
}

Input: crt_tell.txt

Line one.
Line two.

Output

Current file position is: 20

See also

Low-level I/O
ftell, _ftelli64
_lseek, _lseeki64