标签:os io ar 文件 sp amp on c window
#include "stdafx.h"
#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>
#include <string.h>
void FindDir(char* parent)
{
HANDLE hFile = NULL;
WIN32_FIND_DATAA fd = {0};
char tmp[MAX_PATH] = {0};
char sub[MAX_PATH] = {0};
sprintf_s(tmp, "%s\\*.*", parent);
hFile = FindFirstFileA(tmp, &fd);
if(hFile != INVALID_HANDLE_VALUE)
{
do
{
if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(*fd.cFileName == ‘.‘)
continue;
printf("%s\\%s\n", parent, fd.cFileName);
sprintf_s(sub, "%s\\%s", parent, fd.cFileName);
FindDir(sub);
}
}while(FindNextFileA(hFile, &fd));
FindClose(hFile);
hFile = NULL;
}
}
int main(void)
{
char parent[MAX_PATH];
printf("父目录(不包含\"\\\"):");
fgets(parent, MAX_PATH, stdin);
*strrchr(parent, ‘\n‘) = 0;
FindDir(parent);
return 0;
}
标签:os io ar 文件 sp amp on c window
原文地址:http://www.cnblogs.com/sky-view/p/3943174.html