Borland C++ reference

tell

raw OCR

Gets the current position of a file pointer.

Defined in header <io.h>

Syntax

#include <io.h>   -
long tell(int handle);
tell gets the current position of the filepointer associated with handle and

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

expresses it as the number of bytes from the beginning of the file.

Return value

tell returns the current file pointer position. A return of -1 (long) indicates an error, and the global variable errno is set to

EBADF Bad file number

See also

Example

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

int main (void)
{
   int handle;
   char msg[] =  "Hello world";
   if ((handle = open( "TEST.$$$", 0_CREAT I 0_TEXT  j 0_APPEND)) == -1) {
      perror("Error: ");
      return 1;
   }
   write(handle, msg,  strlen(msg));
   printf("The file pointer  is at byte %ld\n", tell (handle));
   close(handle) ;
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.