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++ 3.0r4 - <b>fseek</b> 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);

   ANSI

Description

   Sets the file position associated with the stream fp. offset is the
   signed offset in bytes relative to that 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 before an 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>
   #include <stdlib.h>

   int 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 start of file*/
       fseek(fp, 200L,SEEK_SET);   /*Move to offset 200   */
       return EXIT_SUCCESS;
   }

Return Value

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

See Also

   ftell, lseek



See Also: ftell lseek

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