Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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: