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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Reading from a file3m 25s
-
(Locked)
Writing to a file3m 24s
-
(Locked)
Working with raw data2m 53s
-
(Locked)
Using random file access2m 47s
-
(Locked)
Manipulating files2m 57s
-
(Locked)
Exploring the path2m 8s
-
(Locked)
Reading a directory2m 53s
-
(Locked)
Getting file information2m 46s
-
(Locked)
Using command line arguments2m 44s
-
(Locked)
Calling the operating system2m 46s
-
(Locked)
Challenge: Read and store filenames1m 6s
-
(Locked)
Solution: Read and store filenames2m 52s
-
-
-