This code show the files in a directory. But how to show and the files in the subdirectories Code: #include <iostream> #include <windows.h> using namespace std; int main() { WIN32_FIND_DATA fd; HANDLE hFind; hFind = FindFirstFile("C:\\C++\\*", &fd); cout<<fd.cFileName<<"\n"; while(FindNextFile(hFind, &fd) != 0) { cout<<fd.cFileName<<"\n"; } FindClose(hFind); return 0; }
You move your code into main to some other function and loop through it recursively to populate for all the directories and sub-directories.