Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>fgetpos() get stream position indicator</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fgetpos()               Get stream position indicator

 #include   <stdio.h>

  int fgetpos(stream, pos);
  FILE *stream;     Target stream
  fpos_t *pos; Position indicator storage

    fgetpos() gets the current position of the stream pointer and stores
    it in the object that pos points to. The fsetpos() function can later
    use this information to reset stream's pointer to that position.

    Returns:    fgetpos() returns 0 if successful. If unsuccessful it
                returns a non-zero value and sets errno to one of the
                following manifest constants:

                    Constant   Meaning
                    --------   ------------------------------
                    EINVAL     The stream value is invalid
                    EBADF      The stream is not a valid file handle or
                               is not accessible

      Notes:    fgetpos() and fsetpos() are intended to  allow random
                access operation on files which are too large to handle
                with fseek() and ftell().

                The pos value is stored in an internal format and is
                intended for use only by the fgetpos() and fsetpos()
                functions.

   Portability:     ANSI

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

 This program reads data from a stream, saves the stream pointer position,
 reads more data, then returns to the saved position

           #include <stdio.h>

           FILE *stream;
           fpos_t *pos;

           main()
           {
              . . . open a stream
              . . . read some data

              /* get stream pointer position */
              if (fgetpos(stream, pos) != 0)
                  perror("Unable to get stream pointer position");

              . . . read some more data

              /* return to saved stream pointer position */
              if (fsetpos(stream, pos) != 0)
                  perror("Unable to set stream pointer position");
           }


See Also: fsetpos() fseek() ftell() fopen() fread() fwrite()

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