mirror of
https://github.com/ada-dmitry/prog.l_ada.git
synced 2026-09-24 17:20:16 +00:00
29 lines
523 B
C
29 lines
523 B
C
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <dirent.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
|
|
struct dirent **namelist;
|
|
int n;
|
|
char dir[255] = ".";
|
|
|
|
if (argc > 1)
|
|
strcpy(dir, argv[1]);
|
|
n = scandir(dir, &namelist, 0, alphasort);
|
|
if (n < 0)
|
|
perror("scandir");
|
|
else
|
|
{
|
|
while (n--)
|
|
{
|
|
printf("%s\n", namelist[n]->d_name);
|
|
free(namelist[n]);
|
|
}
|
|
free(namelist);
|
|
}
|
|
return 0;
|
|
} |