Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fsetpos(DOS) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          fsetpos - Sets the file position indicator for a stream.

     Syntax
          #include <stdio.h>

          int fsetpos(stream, pos)
          FILE *stream;
          const fpos_t *pos;


     Description
          The fsetpos function sets the file position indicator for
          stream to the value of pos, which is obtained in a prior
          call to fgetpos against stream.

          The function clears the end-of-file indicator and undoes any
          effects of the ungetcstream.  After calling fsetpos, the
          next operation on stream may be either input or output.

     Return Value
          If successful, the fsetpos function returns 0.  On failure,
          the function returns a nonzero value and sets errno to one
          of the following manifest constants (defined in stdio.h):

          Constant    Meaning
          EINVAL      An invalid stream  value was passed.

          EBADF       The object that stream points to is
                      not a valid file handle, or the file
                      is not accessible.

     See Also
          fgetpos(DOS)



























     Page 1                                          (printed 6/18/89)






     FSETPOS(DOS)              UNIX System V              FSETPOS(DOS)



     Example
          #include <stdio.h>

          FILE *stream; fpos_t pos[]; int val; char list[100];

          main() {
                 if ((stream = fopen("file1","rb")) == NULL)  /* open
          file1 */
                          printf ("Trouble opening file\n");
                 else {
                          fread(list,sizeof(char),100,stream);     /*
          Read some data */
                          if (fgetpos(stream,pos) != 0)     /* Save
          current position */
                                  perror("fgetpos error");
                          fread(list,sizeof(char),100,stream);     /*
          Read some more */
                          if (fsetpos(stream,pos) != 0)  /* Return to
          saved position */
                                  perror("fsetpos error");
                 } }

          This program opens the file named file1 and reads 100
          characters. It then uses fgetpos to find and save the file
          position pointer. After performing another read, the program
          calls fsetpos  to restore the file pointer to the saved
          position.




























     Page 2                                          (printed 6/18/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026