delorie.com/djgpp/doc/libc/libc_354.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <stdio.h> int fseek(FILE *file, long offset, int mode); |
This function moves the file pointer for file according to mode:
SEEK_SET
The file pointer is moved to the offset specified.
SEEK_CUR
The file pointer is moved relative to its current position.
SEEK_END
The file pointer is moved to a position offset bytes from the end of the file. The offset is usually nonpositive in this case.
Warning! The ANSI standard only allows values of zero for
offset when mode is not SEEK_SET
and the file has
been opened as a text file. Although this restriction is not enforced,
beware that there is not a one-to-one correspondence between file
characters and text characters under MS-DOS, so some fseek
operations may not do exactly what you expect.
Also, since lseek
under DOS does not return an error indication
when you try to move the file pointer before the beginning of the file,
neither will fseek
. Portable programs should call ftell
after fseek
to get the actual position of the file pointer.
Note that DOS does not mind if you seek before the beginning of the
file, like seeking from the end of the file by more than the file's
size. Therefore, lseek
will not return with an error in such
cases either.
Zero if successful, nonzero if not.
ANSI/ISO C | C89; C99 |
POSIX | 1003.2-1992; 1003.1-2001 |
fseek(stdin, 12, SEEK_CUR); /* skip 12 bytes */ |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |