fgetpos >> gets the current file pointer position >> Stdio.h function
fgetpos :
- fgetpos gets the current file pointer position.
- fgetpos stores the position of the file pointer associated with the given stream in the location *pos.
- The exact value is irrelevant.
Syntax :
int fgetpos(FILE *stream, fpos_t *pos);Live Example :
char s[100];
fpos_t pos;
fgets(s, sizeof(s), fp); // read a line from the file
fgetpos(fp, &pos); // save the position
fgets(s, sizeof(s), fp); // read another line from the file
fsetpos(fp, &pos); // now restore the position to where we savedReturn Value :
- On success : Return 0
- On Error : Returns a non-zero value