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.
Working with raw data - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Working with raw data
- [Instructor] The file versions of the standard CIO functions write text. To read and write raw data, you use the F read and F write functions. and closing functions remain the same. So, in this exercise file, 10 integers are written to the file integers.dat, which is created as a string constant at line five. Then at line 10, the files open for writing using the standard F open function with W as the mode. A loop at line 19 writes the 10 integers. The the F write statement at line 21 consumes four arguments. The first is the address of the variable that contains the value to write. In this case, it's variable A initialized at line 18, and then incremented by five in line 22 each time the loop spins. The second argument is the size of the data chunk to write. I use the size of operator on an integer to obtain that size. The third argument is the number of chunks to write, one in this case, one integer, and the fourth argument is the file handle, build and run. The code has no…
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
-
-
-