fsetpos : fsetpos « stdio.h « C Tutorial






ItemValue
Header filestdio.h
Declarationint fsetpos(FILE *stream, const fpos_t *position);
Functionmoves the file position pointer. This value is from fgetpos().
Returnreturns zero on success or nonzero on failure.


#include <stdio.h>
  #include <stdlib.h>

  int main(int argc, char *argv[])
  {
      FILE *fp;
      fpos_t file_loc;

      if((fp=fopen("test","r"))==NULL) {
          printf("Cannot open file.\n");
          exit(1);
      }
   
      fgetpos(fp, &file_loc);

      fsetpos(fp, &file_loc);
     
      fclose(fp);
  }








22.17.fsetpos
22.17.1.fsetpos