1
0

strinput4 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. FSEEK(3) Linux Programmer's Manual FSEEK(3)
  2. NAME
  3. fgetpos, fseek, fsetpos, ftell, rewind - reposition a stream
  4. SYNOPSIS
  5. #include <stdio.h>
  6. int fseek(FILE *stream, long offset, int whence);
  7. long ftell(FILE *stream);
  8. void rewind(FILE *stream);
  9. int fgetpos(FILE *stream, fpos_t *pos);
  10. int fsetpos(FILE *stream, fpos_t *pos);
  11. DESCRIPTION
  12. The fseek() function sets the file position indicator for the stream
  13. pointed to by stream. The new position, measured in bytes, is obtained
  14. by adding offset bytes to the position specified by whence. If whence
  15. is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to
  16. the start of the file, the current position indicator, or end-of-file,
  17. respectively. A successful call to the fseek() function clears the
  18. end-of-file indicator for the stream and undoes any effects of the
  19. ungetc(3) function on the same stream.
  20. The ftell() function obtains the current value of the file position
  21. indicator for the stream pointed to by stream.
  22. The rewind() function sets the file position indicator for the stream
  23. pointed to by stream to the beginning of the file. It is equivalent
  24. to:
  25. (void) fseek(stream, 0L, SEEK_SET)
  26. except that the error indicator for the stream is also cleared (see
  27. clearerr(3)).
  28. The fgetpos() and fsetpos() functions are alternate interfaces equiva‐
  29. lent to ftell() and fseek() (with whence set to SEEK_SET), setting and
  30. storing the current value of the file offset into or from the object
  31. referenced by pos. On some non-UNIX systems an fpos_t object may be a
  32. complex object and these routines may be the only way to portably repo‐
  33. sition a text stream.
  34. RETURN VALUE
  35. The rewind() function returns no value. Upon successful completion,
  36. fgetpos(), fseek(), fsetpos() return 0, and ftell() returns the current
  37. offset. Otherwise, -1 is returned and errno is set to indicate the
  38. error.
  39. ERRORS
  40. EBADF The stream specified is not a seekable stream.
  41. EINVAL The whence argument to fseek() was not SEEK_SET, SEEK_END, or
  42. SEEK_CUR.
  43. The functions fgetpos(), fseek(), fsetpos(), and ftell() may also fail
  44. and set errno for any of the errors specified for the routines
  45. fflush(3), fstat(2), lseek(2), and malloc(3).
  46. CONFORMING TO
  47. C89, C99.
  48. SEE ALSO
  49. lseek(2), fseeko(3)
  50. COLOPHON
  51. This page is part of release 3.35 of the Linux man-pages project. A
  52. description of the project, and information about reporting bugs, can
  53. be found at http://man7.org/linux/man-pages/.
  54. GNU 1993-11-29 FSEEK(3)