From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Reading from a file - C Tutorial
From the course: Complete Guide to C Programming Foundations
Reading from a file
- [Instructor] To access or open a file in C, you must know that the file exists. You must know the file's name. For now, assume that the file dwells in the same directory as the program opening the file. To make all this magic happen, you take these details and you use the fopen function to open the file. The app open function is prototyped in the stdio.h header file. It requires two arguments. The first is the file name, a string. The second is a string representing the file mode or how to open the file. Two common file modes are R for reading and W for writing. The fopen function returns a file pointer, which is also called a file handle. The file pointer variable is declared in this manner, with handle as the variable name. You must test the file pointer against the null constant to ensure that the file was open properly. If the values aren't equal, the file handle references a structure used by other file access functions to do things with the open file. After it's opened, you…
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Reading from a file3m 31s
-
(Locked)
Writing to a file3m 40s
-
(Locked)
Challenge: Writing and reading files1m
-
(Locked)
Solution: Writing and reading files4m 4s
-
(Locked)
Working with raw data3m 4s
-
(Locked)
Using random file access3m 21s
-
(Locked)
Challenge: Access database records56s
-
(Locked)
Solution: Access database records2m 51s
-
(Locked)
Manipulating files2m 34s
-
(Locked)
Exploring the path1m 50s
-
(Locked)
Reading a directory3m 36s
-
(Locked)
Getting file information3m 26s
-
(Locked)
Chapter challenge: Managing files1m 46s
-
(Locked)
Chapter solution: Managing files2m 50s
-
(Locked)
-
-