fseekΒΆ
fseek moves the file pointer to a new position.
-
bool = fseek(fh)
-
bool = fseek(fh, nSeek)
-
bool = fseek(fh, nSeek, nOrigin)
Return Value
If the function succeeds, the return value is TRUE (1); otherwise it is FALSE (0).
Parameters
-
fh
Identifies the file.
-
nSeek
nSeek is the number of bytes from nOrigin.
-
nOrigin
nOrigin is one of the following values:
Value | Meaning |
---|---|
SEEK_CUR (1) | Current position of file pointer. |
SEEK_END (2) | End of the file. |
SEEK_SET (0) | Beginning of file (default value). |
Example
fh = fopen("c:/test.bin", "w+");
// write 100 short values
fwrite(fh, "int16", 1:100);
print fseek(fh, -100, SEEK_CUR);
// read 50 short values
rvValues = fread(fh, "int16", 50);
fclose(fh);
print rvValues';
History
Version | Description |
---|---|
5.3.0 | nSeek can be larger than 32 bit. |
See also
id-625630