I am using the following code to iterate through files in the directory. All the files in this directory are numbered, each with a unique number.
The code below successfully prints out all the files in the directory however not in ascending order. It comes out completely random and one file is duplicated.
I can't find another way of printing out the files or printing them in ascending order. I really need to print them in ascending order and then later open them in ascending order. Any help is appreciated.
DIR *dpdf;
struct dirent *epdf;
dpdf = opendir("/data/files");
if (dpdf != NULL){
while (epdf = readdir(dpdf)){
printf("%s\n",epdf->d_name);
// std::out << epdf->d_name << std::endl;
}
}