I want to list the files in this folder \"C:\\home\\WORK\\Desktop\\Communication\". There are ten files in this folder. My code has no error but it\'s not printing anything. Wh
Seems, you should move
numberOfFiles++
past
printf("%s\n",files[numberOfFiles]);
Or
while((FindNextFile(hFind,&fdata))!=0)
{
files[numberOfFiles]=fdata.cFileName;
printf("%s\n", files[numberOfFiles++]);
}
Which is same as
while((FindNextFile(hFind,&fdata))!=0)
{
printf("%s\n", files[numberOfFiles++] = fdata.cFileName);
}
I don't know WinAPI well, but I feel, that all files will contain invalid pointers after FindClose(hFind) as well as all elements of files will point to *(fdata.cFileName) which will be released in FindClose(hFind). In other words, as I understand this, you should copy (or duplicate) fdata.cFileName into files[i] on each iteration.