From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Challenge: Writing and reading files - C Tutorial
From the course: Complete Guide to C Programming Foundations
Challenge: Writing and reading files
(bright music) - [Instructor] Time to put your file opening, reading, and writing skills to the test. Your task is to create a file named hello.txt for output. Prompt the user to input their name, write their name to the hello text file in the format, name has written to this file. Then close the file, but you're not done. In the same source code file, the same program, reopen that file for reading. Read in the single line of text that's stored in the file, then output the line of text. This task isn't that complicated, but it does involve quite a few lines of code. Add comments to the code to introduce and explain each step taken. It's okay to use the same file handle each time you open the file and feel free to use the code skeleton provided in the exercise files. This challenge should take you about 15 minutes to complete.
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)
-
-