Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>tell() get current file pointer position</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 tell()                  Get Current File Pointer Position

 #include   <io.h>                       Required for declarations only

 long       tell(handle);
 int        handle;                      Handle referring to open file

    tell() gets the current position of the file pointer associated with
    'handle'.  The position is returned as the number of bytes from the
    beginning of the file.

       Returns:     The current file-pointer position, if successful; -1L
                    if an error occurs. On error, 'errno' is set to EBADF
                    (invalid file handle)

         Notes:     tell() does not reposition the pointer.

   -------------------------------- Example ---------------------------------

    The following statements open a file, get the current position, move
    to a different position, then restore the pointer to the saved
    position.

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

           int fhndl;
           long position;

           main()
           {
               fhndl = open("c:\comp\invoice.dat",O_RDWR);
               .
               .
               position = tell(fhndl);
               lseek(fhndl,0L,SEEK_SET);
               .
               .
               lseek(fhndl,position,0);
           }


See Also: ftell() lseek()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson