Reposition file pointer to a saved location: how to use fsetpos : File Pointer « File « C / ANSI-C






Reposition file pointer to a saved location: how to use fsetpos



#include <stdio.h>

int main ()
{
  FILE * file;
  fpos_t pos;

  file = fopen ("my.txt", "w");
  
  fgetpos(file, &pos);
  
  fputs ("That is a line." ,file);
  
  fsetpos (file, &pos);
  fputs ("This", file);
  
  fclose (file);
  return 0;
}

           
       








Related examples in the same category

1.Reset file position indicator to start of the file
2.Set the file pointer to the beginning of a stream: how to use rewind
3. Return the current position in a stream: how to use ftell