fseek(3) Library Functions Manual fseek(3) fgetpos, fseek, fsetpos, ftell, rewind - LIBRARY Standard C library (libc, -lc) #include int fseek(FILE *stream, long offset, int whence); long ftell(FILE *stream); void rewind(FILE *stream); int fgetpos(FILE *restrict stream, fpos_t *restrict pos); int fsetpos(FILE *stream, const fpos_t *pos); fseek() , stream. ( ) offset , whence. whence SEEK_SET, SEEK_CUR SEEK_END, , , . fseek() (clear) ungetc(3) . ftell() , stream. rewind() , stream, . : (void) fseek(stream, 0L, SEEK_SET) ( clearerr(3)). fgetpos() fsetpos() ftell() fseek() ( whence SEEK_SET); , pos. -UNIX fpos_t , . If the stream refers to a regular file and the resulting stream offset is beyond the size of the file, subsequent writes will extend the file with a hole, up to the offset, before committing any data. See lseek(2) for details on file seeking semantics. rewind() . fgetpos(), fseek(), fsetpos() 0, ftell() . -1, errno . EINVAL whence fseek() SEEK_SET, SEEK_ SEEK_CUR. . ESPIPE stream ( , FIFO ). fgetpos(), fseek(), fsetpos() ftell() errno , fflush(3), fstat(2), lseek(2) malloc(3). attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |fseek(), ftell(), rewind(), | | MT-Safe | |fgetpos(), fsetpos() | | | +----------------------------+----------------------------------------------------------+--------------------------+ C11, POSIX.1-2008. POSIX.1-2001, C89. . lseek(2), fseeko(3) Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . fseek(3)