2022-10-23 12:41:45 +00:00
|
|
|
#include <dirent.h>
|
2022-10-23 12:06:11 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2022-10-23 12:41:45 +00:00
|
|
|
DIR* dp = opendir("/bin");
|
|
|
|
if (!dp)
|
2022-10-23 12:06:11 +00:00
|
|
|
{
|
2022-10-23 12:41:45 +00:00
|
|
|
perror("opendir");
|
2022-10-23 12:06:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
do {
|
2022-10-23 12:41:45 +00:00
|
|
|
struct dirent* ent = readdir(dp);
|
|
|
|
if (!ent) break;
|
|
|
|
printf("%s\n", ent->d_name);
|
|
|
|
} while (1);
|
2022-10-23 12:06:11 +00:00
|
|
|
|
2022-10-23 12:41:45 +00:00
|
|
|
closedir(dp);
|
2022-10-23 12:06:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|