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>lseek</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
lseek

Usage

   #include <io.h>
   long lseek(int fd,long offset,int mode);

Description

   lseek changes the read/write pointer for a file given by file descriptor
   fd. Values for mode are:

   SEEK_SET    The pointer is moved to offset bytes from the
               beginning  of the file.

   SEEK_CUR    Moved to the current location plus offset.

   SEEK_END    Moved to the end of the file plus the offset.

Example 

   #include <stdio.h>
   #include <io.h>
   #include <dos.h>
   #include <stdlib.h>

   int main()

   {
       int fp;
       long offset,lpos;
       fp = open("file.dat",O_RDWR);
       if(fp <  0) return;
       offset = 0L;
       lpos = lseek(fp,offset,SEEK_SET);
       printf("Current position of seek = %ld\n",lpos);
       offset = 10L;
       lpos = lseek(fp,offset,SEEK_CUR);
       printf("Current position of seek = %ld\n",lpos);
       offset = 50L;
       lpos = lseek(fp,offset,SEEK_END);
       printf("Current position of seek = %ld\n",lpos);
       close(fp);
       return EXIT_SUCCESS;
   }

Return Value

   lseek returns the offset in bytes of the new position from the beginning
   of the file. A -1 is returned on error, and errno is set.

See Also

   fseek



See Also: fseek

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