0
As I take the filenames of a directory and place 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;
}
First you need to decide whether to do it in C or C++, it looks like C, right? What problem are you having?
– Maniero
c++, but the above code is just c. Problem: I don’t know how to convert "drnt->d_name" to a multidimensional char array. I don’t even know which type is "drnt->d_name" and I don’t even know how to know the type of this variable. "drnt" is a struct and "d_name" is what? a char array?
– PerduGames