Join Dan Gookin for an in-depth discussion in this video Challenge: Read and store filenames, part of C: Data Structures, Pointers, and File Systems.
(upbeat music) … - [Instructor] This challenge is quite involved, … but in the big picture you have three overall tasks: … first prompt the user for a pathname, a directory to read; … second, open that directory and read its full list of files; … third, output that list to a file named filelist.txt. … Here are some suggestions. … Strip out the newline character from user input. … Valid pathnames do not contain a newline character. … Remember that the chdir function returns zero upon success. … This result is how you can both change to a given directory … and validate pathname input. … Finally, the filelist.txt file must be created … in the same directory as the program you create. … So, if the program runs in one directory, … that's the same directory … in which the filelist.txt file must be created. … This challenge could take up to 40 minutes to complete. … …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.