Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

19 lines
353 B
C++

#include <dirent.h>
#include <stdio.h>
#include <cstdlib>
int main()
{ const char* path ="./*";
struct dirent **namelist;
int n = scandir(path, &namelist, NULL, alphasort);
if (n < 0)
{ perror("scandir");
return 1;
}
for(int i=0;i<n;i++)
{ printf("%i: %s\n",i+1,namelist[i]->d_name);
free(namelist[i]);
}
free(namelist);
return 0;
}