fseek changes a file stream’s current position using an offset and a reference specified by whence. SEEK_SET measures from the file start; SEEK_CUR measures from the position before the call. section 14.6
size_t fread(void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
size_t fwrite(void const*restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
int fseek(FILE* stream, long int offset, int whence);
long int ftell(FILE* stream);
The declaration shows fseek’s FILE stream, long offset, and whence arguments alongside fread, fwrite, and ftell. section 14.6
Use fseek with the binary-stream position model:
- Combine fseek with ftell to reposition and inspect a stream’s byte position. section 14.6
- Move forward or backward through a file, then read or write bytes at the resulting position. section 14.6
- Open streams used with binary I/O in binary mode for portability. section 14.6
