fseek(3)


NAME

   fgetpos, fseek, fsetpos, ftell, rewind - reposition a stream

SYNOPSIS

   #include <stdio.h>

   int fseek(FILE *stream, long offset, int whence);

   long ftell(FILE *stream);

   void rewind(FILE *stream);

   int fgetpos(FILE *stream, fpos_t *pos);
   int fsetpos(FILE *stream, const fpos_t *pos);

DESCRIPTION

   The  fseek()  function  sets the file position indicator for the stream
   pointed to by stream.  The new position, measured in bytes, is obtained
   by  adding offset bytes to the position specified by whence.  If whence
   is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset  is  relative  to
   the  start of the file, the current position indicator, or end-of-file,
   respectively.  A successful call to the  fseek()  function  clears  the
   end-of-file  indicator  for  the  stream  and undoes any effects of the
   ungetc(3) function on the same stream.

   The ftell() function obtains the current value  of  the  file  position
   indicator for the stream pointed to by stream.

   The  rewind()  function sets the file position indicator for the stream
   pointed to by stream to the beginning of the file.   It  is  equivalent
   to:

          (void) fseek(stream, 0L, SEEK_SET)

   except  that  the  error  indicator for the stream is also cleared (see
   clearerr(3)).

   The  fgetpos()  and  fsetpos()  functions  are   alternate   interfaces
   equivalent  to  ftell()  and  fseek()  (with  whence  set to SEEK_SET),
   setting and storing the current value of the file offset into  or  from
   the  object  referenced  by  pos.   On some non-UNIX systems, an fpos_t
   object may be a complex object and these routines may be the  only  way
   to portably reposition a text stream.

RETURN VALUE

   The  rewind()  function  returns no value.  Upon successful completion,
   fgetpos(), fseek(), fsetpos() return 0, and ftell() returns the current
   offset.   Otherwise,  -1  is  returned and errno is set to indicate the
   error.

ERRORS

   EBADF  The stream specified is not a seekable stream.

   EINVAL The whence argument to fseek() was not  SEEK_SET,  SEEK_END,  or
          SEEK_CUR.  Or: the resulting file offset would be negative.

   The  functions fgetpos(), fseek(), fsetpos(), and ftell() may also fail
   and set errno  for  any  of  the  errors  specified  for  the  routines
   fflush(3), fstat(2), lseek(2), and malloc(3).

ATTRIBUTES

   For   an   explanation   of   the  terms  used  in  this  section,  see
   attributes(7).

   ┌────────────────────────────┬───────────────┬─────────┐
   │InterfaceAttributeValue   │
   ├────────────────────────────┼───────────────┼─────────┤
   │fseek(), ftell(), rewind(), │ Thread safety │ MT-Safe │
   │fgetpos(), fsetpos()        │               │         │
   └────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

   POSIX.1-2001, POSIX.1-2008, C89, C99.

SEE ALSO

   lseek(2), fseeko(3)

COLOPHON

   This page is part of release 4.09 of the Linux  man-pages  project.   A
   description  of  the project, information about reporting bugs, and the
   latest    version    of    this    page,    can     be     found     at
   https://www.kernel.org/doc/man-pages/.


More Linux Commands

manpages/mvin_wchnstr.3ncurses.html
mvin_wchnstr(3ncurses) - get an array of complex characters
These functions return an array of complex characters in wchstr, starting at the current cursor position in the named window. Attributes (rendition) are stored

manpages/gnutls_pkcs7_get_crl_count.3.html
gnutls_pkcs7_get_crl_count(3) - API function (Man Page).....
This function will return the number of certifcates in the PKCS7 or RFC2630 crl set. RETURNS On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative

manpages/whline.3ncurses.html
whline(3ncurses) - create curses borders, horizontal and ver
The border, wborder and box routines draw a box around the edges of a window. Other than the window, each argument is a character with attributes: ls - left sid

manpages/circo.1.html
circo(1) - filter for circular layout of graphs (Man Page)
These are a collection of programs for drawing graphs. There is actually only one main program; the specific layout algorithms implemented as plugins. Thus, the

manpages/XcmsCIExyY.3.html
XcmsCIExyY(3) - Xcms color structure - Linux manual page....
The XcmsColor structure contains a union of substructures, each supporting color specification encoding for a particular color space. SEE ALSO XcmsAllocColor(3)

manpages/getkeycodes.8.html
getkeycodes(8) - print kernel scancode-to-keycode mapping ta
The getkeycodes command prints the kernel scancode-to-keycode mapping table. OPTIONS None. SEE ALSO setkeycodes 411toppm(1) getkeycodes.8 (Administration - Linu

manpages/showrgb.1.html
showrgb(1) - display an rgb color-name database (Man Page)
The showrgb program reads an rgb color-name database from a text file and converts it back to source form, printing the result to standard output. The default d

manpages/zdump.8.html
zdump(8) - timezone dumper (Administration - Linux man page)
Zdump prints the current time in each zonename named on the command line. These options are available: --version Output version information and exit. --help Out

manpages/ldap_tls.3.html
ldap_tls(3) - LDAP TLS initialization routines (Man Page)...
These routines are used to initiate TLS processing on an LDAP session. ldap_start_tls_s() sends a StartTLS request to a server, waits for the reply, and then in

manpages/creall.3.html
creall(3) - get real part of a complex number (Man Page)....
The creal() function returns the real part of the complex number z. One has: z = creal(z) + I * cimag(z) VERSIONS These functions first appeared in glibc in ver

manpages/operator.7.html
operator(7) - C operator precedence and order of evaluation
This manual page lists C operators and their precedence in evaluation. Operator Associativity () [] -&gt; . left to right ! ~ ++ -- + - (type) * &amp; sizeof right to

manpages/mallopt.3.html
mallopt(3) set memory allocation parameters - Linux man page
The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see malloc(3)). The param argument specifies the paramet





We can't live, work or learn in freedom unless the software we use is free.