From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using random file access

Using random file access - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Using random file access

- [Instructor] When a file is opened for reading or writing the operating system uses a file position indicator to keep track of where data is written to or read from in the file. Sequential file access reads from or writes to a file one byte after another. The file position indicator keeps moving forward until the EOF is encountered or the FEOF function returns true for a given file handle. With random file access, the file position indicator can be set to any location in a file to read or write data. This feature works best for files that contain uniform data, such as a file of integer values, structures, or similar consistent data. The fseek function controls the file position indicator. Its three arguments are the file handle or stream, a long integer offset representing the offset within the file, and a constant as the third argument representing from whence the offset is measured. Seek_set from the start of the file. Seek_cur from the current file position indicator's location…

Contents