C Now

Handle tell Function

Site Logo

Usage:

The tell function is used to find the current position of a file pointer.

Prototype:

long tell (int Handle);

Argument:

Handle
Selector (file descriptor) of an open file.

Header Files:

io.h
(tell)
errno.h
(errno values)

Returns:

>= 0
File pointer offset from the beginning of the file.
  -1
Failure.

Side Effect:

errno
Iff the tell fails, the global variable errno is set to error code
EBADF
Handle not open

Example:

#include <io.h> 
 .  .  .
  int       Account_Master;
  char      Buffer [100];
  int       Maximum;
  int       Actual;
  long      Pos;
    .  .  .
  Maximum = 100;
    .  .  .
  Account_Master = open ("accounts.dat", O_RDWR);
    .  .  .
  while (!eof (Account_Master)) {
    Pos = tell (Account_Master);
    Actual = read (Account_Master, Buffer, Maximum);
    .  .  .
    /* rewrite the record */
    lseek (Account_Master, Pos, SEEK_SET);
    Actual = write (Account_Master, Buffer, Maximum);
    .  .  .
  }

The io.h Header File Listing  The io.h Header File Listing
The Handle close Function  The Handle close Function
The Handle eof Function  The Handle eof Function
The Handle lseek Function  The Handle lseek Function
The Handle open Function  The Handle open Function
The Handle read Function  The Handle read Function
The Handle write Function  The Handle write Function
C Now Home  C Now Home
Include Files Index  Include Files Index
Header io.h Index  Header io.h Index
E-Mail
Valid HTML 4.01 Transitional Valid CSS! Site Logo

copyright 2001-2006, j.h.young, revised 2/13/06

The io.h Header File Listing / The Handle close Function / The Handle eof Function / The Handle lseek Function / The Handle open Function / The Handle read Function / The Handle write Function /