fsetpos function >> sets file pointer of stream to a new position >> C ProgrammingPritesh
- 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.
int fsetpos(FILE *stream, const fpos_t *pos);
Live Example :int main ()
FILE * fp;
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
Return Value :
- On success : Return 0
- On Error : Returns a non-zero value