_tell

Description

Gets the position of the file pointer.

#include <io.h> Required only for function declarations  

long _tell( int handle );

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.

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.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

See Also

ftell, _lseek

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;

long position;

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: 425