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

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