[prev] [index] [next]

The ftell function

long ftell(FILE *f);
  • returns current offset for stream f (or -1 on error)
  • used to grab current location to return there later
Example of use:

FILE *fp; // open for reading and/or writing
... add some data to stream fp ...
long here = ftell(fp);      // save current location
... add more text to stream fp ...
fseek(fp, here, SEEK_SET);  // return to known location