c语言如何读取一个目录下的所有文件

来源:百度知道 编辑:UC知道 时间:2024/06/04 14:43:56

int main()
{
long file;
struct _finddata_t find;

_chdir("d:\\");
if((file=_findfirst("*.*", &find))==-1L)
{
printf("空白!\n");
exit(0);
}
printf("%s\n", find.name);
while(_findnext(file, &find)==0)
{
printf("%s\n", find.name);
}
_findclose(file);
return 0;
}