- It is used to sets the position to a desired point in the file.
Ex:
fseek (file_pointer, offset, position);
- File pointer is the pointer to the file concerned.
- Offset is a number or variable of type long.
- Position is an integer number.
- Position can take 0 (zero) for beginning of file.
- Position can take 1 (one) for current position of file.
- Position can take 2 (two) for ending of file.
fseek()
operations
Operation
|
Meaning
|
fseek(fp, 0L, 0);
|
Go to beginning
|
fseek(fp, 0L, 1);
|
Stay at the current
position
|
fseek(fp, 0L, 2);
|
Go to end of the
file
|
fseek(fp, m, 0);
|
Move to m+1 byte in
the file
|
fseek(fp, m, 1);
|
Go forward by m
bytes
|
fseek(fp, -m, 1);
|
Go backward by m
bytes
|
fseek(fp, -m, 2);
|
Go backward by m
bytes from the end.
|
No comments:
Post a Comment