How do I get the names of the files in a directory and put them in a multidimensional char array?
#include <stdio.h>
#include <dirent.h>
int main()
{
char arrayNomes[10][50];
char dirn[50];
DIR *dir = NULL;
struct dirent *drnt = NULL;
dir = opendir(dirn);
if (dir)
{
while (drnt = readdir(dir))
{
printf("%s\n", drnt->d_name);
//Como fazer algo como isso abaixo:
for (...)
{
arrayNomes[i] = drnt->d_name;
}
}
closedir(dir);
}
else
{
printf("Can not open directory '%s'\n", dirn);
}
return 0;
}