tell

De RAD Studio
Aller à : navigation, rechercher

Remonter à io.h - Index

Header File

io.h

Category

Input/output Routines

Prototype

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

Description

Gets the current position of a file pointer.

tell gets the current position of the file pointer associated with handle and 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 -1L indicates an error, and the global variable errno is set to

EBADF

Bad file handler


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.$$$", O_CREAT | O_TEXT | O_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;
}

Portability

POSIX Win32 ANSI C ANSI C++

+