
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Telix/SALT v3.15 & RS-232, Hayes - <b>fseek</b>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
FSEEK
. Summary
fseek(int <fh>, int <offset>, int <origin>);
. Description
The fseek function sets the position of the file pointer in the file
represented by the file handle <fh>. The file position is where the
next read or write will take place. <offset> is the signed offset
from the location specified by <origin>. Legal values for <origin>
are:
0: Beginning of file.
1: Current position.
2: End of file.
The pointer can be positioned anywhere in the file, and even past
the end of the file (which will extend it). It is illegal to try to
position the pointer before the beginning of the file however.
. Return Value
If successful, fseek returns a 0 value, otherwise a non-zero value
is returned.
. Example
int f;
f = fopen("test.dat", "r");
fseek(f, 0, 0); // go to offset 0 in file
fseek(f, 1000, 0); // go to offset 1000 in file
fseek(f, -5, 1); // go back 5 places in file
fseek(f, 0, 2); // go to the end of the file
See Also: ftell
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson