我想列出文件夹“C:\ home \ WORK \ Desktop \ Communication”中的文件。该文件夹中有十个文件。我的代码没有错误,但没有打印任何内容。我的错误是什么?声明之后在Windows中使用C列出文件夹中的文件
#include<stdio.h>
#include<Windows.h>
#include<string.h>
int main(int argc,char *argv[])
{
char path[]="C:\\home\\WORK\\Desktop\\Communication";
strcat_s(path,sizeof(path),"\\*");
WIN32_FIND_DATA fdata;
HANDLE hFind =INVALID_HANDLE_VALUE;
int numberOfFiles=0;
char *files[10];
hFind = FindFirstFile(path,&fdata);
while((FindNextFile(hFind,&fdata))!=0)
{
files[numberOfFiles]=fdata.cFileName;
numberOfFiles++;
printf("%s\n",files[numberOfFiles]);
}
FindClose(hFind);
return 0;
}