I have this code that print list of directory.
How to save that list of directory in global array and print that global array from main function ?
#include <stdio.h>
#include <dirent.h>
void listFiles(const char* dirname)
{
DIR* dir = opendir(dirname);
if(dir == NULL)
{
return ;
}
struct dirent* entity ;
entity = readdir(dir);
while(entity != NULL)
{
printf("%s\n", entity->d_name);
entity = readdir(dir);
}
closedir(dir);
return;
}
int main()
{
listFiles(".");
return 0;
}