fsetpos
int fsetpos ( FILE * stream , const fpos_t * position ); | stdio.h |
cplusplus.com |
Reposition file pointer to a saved location.
Sets the file pointer associated with stream to a new
position. The position parameter is a value previously obtained by a
call to fgetpos.
After a call to this function, the End-Of-File indicator of the stream is cleared
and any effect of a previous call to ungetc is undone.
The next operation with the stream after a call to fsetpos can be either for
input or output.
Parameters.
Return Value.
If successful the function returns 0.
Otherwise it returns nonzero and sets
the global variable errno to a non-zero value.
Portability.
Defined in ANSI-C.
Example.
/* fsetpos example */
#include <stdio.h>
main ()
{
FILE * pFile;
fpos_t position;
pFile = fopen ("myfile.txt","w");
fgetpos (pFile, &position);
fputs ("That is a sample",pFile);
fsetpos (pFile, &position);
fputs ("This",pFile);
fclose (pFile);
return 0;
}
After this code is executed, a file called myfile.txt will
be created and will contain the sentence
This is a sample
See also.
fopen,
fgetpos,
fseek
ftell,
frewind