What is the correct way to read and extract data from text files when you know that there will be many in a directory? I know that you can use fopen() to get the pointer to the file, and then do something like while(fgets(..) != null){} to read from the entire file, but then how could I read from another file? I want to loop through every file in the directory.
What is the correct way to read and extract data from text files when
Share
Sam, you can use opendir/readdir as in the following little function.
This just opens a directory named on the command line and prints the names of all files it contains. But instead of printing the names, you can process the files as you like…