int fseek (FILE *stream, long offset, int fromwhere);
fseek is used to open files in binary mode, move file read/write pointer position.
int fseek (FILE *stream, long offset, int origin);the first parameter stream is a file pointer
The second parameter offset is the offset, the integer represents the forward offset, and the negative number represents the negative offset
The third parameter, origin, sets the offset from where the file begins, possibly with a value of: Seek_cur, Seek_end, or Seek_set
seek_set: File Start
seek_cur: Current Location
seek_end: End of File
where Seek_set,seek_cur and Seek_end and sequentially 0, 1 and 2.
In short:
fseek (fp,100l,0); Move the fp pointer to 100 bytes from the beginning of the file;
fseek (fp,100l,1); Move the fp pointer to 100 bytes from the current position of the file;
fseek (fp,100l,2); Returns the fp pointer to 100 bytes from the end of the file.
File operation: fseek ()