fsetpos function >> sets file pointer of stream to a new position >> C Programming
fgetpos :
- Header File : Stdio.h
- fsetpos sets [positions] the file pointer of a stream
- fsetpos sets the file pointer associated with stream to a new position.
- The new position is the value obtained by a previous call to fgetpos on that stream.
- Fsetpos also clears the end-of-file indicator on the file *stream and undoes any effects of ungetc on that file.
- fgetpos stores the position of the file pointer associated with the given stream in the location *pos.
- The exact value is irrelevant.
Syntax :
int fsetpos(FILE *stream, const fpos_t *pos);Live Example :
int main ()
{
FILE * fp;
fpos_t position;
fp = fopen ("file1.txt","w");
fgetpos (fp, &position); // Store New Position
fputs ("What an Idea",fp);
fsetpos (fp, &position); // Set Current Position to New Position
fputs ("This",fp);
fclose (fp);
return 0;
}Return Value :
- On success : Return 0
- On Error : Returns a non-zero value