Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <io.h>
    long int tell( int handle );

Description:
    The tell function determines the current file position at the operating
    system level.  The handle value is the file handle returned by a
    successful execution of the  open function.

    The returned value may be used in conjunction with the  lseek function
    to reset the current file position.

Returns:
    When an error occurs, -1 is returned.  When an error has occurred,
     errno contains a value indicating the type of error that has been
    detected.

    Otherwise, the current file position is returned in a system-dependent
    manner.  A value of 0 indicates the start of the file.

See Also:
    chsize, close, creat, dup, dup2, eof, exec Functions Functions, filelength,
    fileno, fstat, isatty, lseek, open, read, setmode, sopen, stat, write,
    umask

Example:
    #include <stdio.h>
    #include <sys\stat.h>
    #include <io.h>
    #include <fcntl.h>

    char buffer[]
            = { "A text record to be written" };

    void main()
      {
        int handle;
        int size_written;

        /* open a file for output             */
        /* replace existing file if it exists */
        handle = open( "file",
                    O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
                    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );

        if( handle != -1 ) {

          /* print file position */
          printf( "%ld\n", tell( handle ) );

          /* write the text */
          size_written = write( handle, buffer,
                                sizeof( buffer ) );

          /* print file position */
          printf( "%ld\n", tell( handle ) );

          /* close the file */
          close( handle );
        }
      }

    produces the following:

    0
    28

Classification:
    WATCOM

Systems:
    All

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