Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 4. Files and File I/O > Random Access: Moving Around within a File

4.5. Random Access: Moving Around within a File

So far, we have discussed sequential I/O, whereby data are read or written beginning at the front of the file and continuing until the end. Often, this is all a program needs to do. However, it is possible to do random access I/O; that is, read data from an arbitrary position in the file, without having to read everything before that position first.

The offset of a file descriptor is the position within an open file at which the next read or write will occur. A program sets the offset with the lseek() system call:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial