6.3w+
社区成员
#include "windows.h"
#include "iostream"
using namespace std;
void search(char path[]) {
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
char filePath[128];
char fileName[128];
bool bWork = true;
sprintf(filePath, "%s\\*", path);
hFind = FindFirstFile(filePath, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
return;
while (bWork) {
if (strcmp(FindFileData.cFileName, ".") && strcmp(FindFileData.cFileName, "..")) {
sprintf(fileName, "%s\\%s", path, FindFileData.cFileName);
if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
search(fileName);
else
cout<<fileName<<endl;
}
bWork = FindNextFile(hFind, &FindFileData);
}
FindClose(hFind);
}
int main()
{
FILE* file = freopen("out.txt", "w", stdout);
search("E:\\");
fclose(file);
return 0;
}