Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - fseek http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   fseek

   Usage
   #include <stdio.h>
   #include <io.h>
   int fseek(FILE *fp,long offset,int origin);

   Description
   Sets  the file position associated with the stream fp. Offset  is  the
   signed offset in bytes relative to what is specified by origin. Values
   for origin are defined in io.h:

   SEEK_SET       beginning of file
   SEEK_CUR       current position
   SEEK_END       end of file

   If  the  file  is  opened in text mode, offset can  only  be  a  value
   returned  by ftell and origin can only be SEEK_SET, or offset must  be
   0. If an ungetc was done immediately preceding a fseek, the ungetc  is
   undone.  If  the  file  was opened in  read/write  mode  (see  fopen),
   following the fseek either reading or writing may be performed.

   Example
   #include <stdio.h>
   #include <io.h>
   main()
   {
   FILE *fp;
        fp = fopen("file.dat","r+");
        fseek(fp, 0L,SEEK_END);/* Move to end of file */
        fseek(fp, 0L,SEEK_SET);/* Move to beginning of file */
        fseek(fp, 200L,SEEK_SET);/* Move to offset 200 */
   }

   Return Value
   fseek  returns 0 if the pointer was successfully moved. fseek  returns
!=0 if an error occurred.


See Also: ftell lseek

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson