#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <dirent.h>
static int get_files()
{
DIR *dirp;
struct dirent *dp;
dirp = opendir(".");
if (dirp == NULL) {
return -1;
}
while ((dp = readdir(dirp)) != NULL) {
printf("%s\n", dp->d_name);
}
(void) closedir(dirp);
return 0;
}
int main(int argc, char const *argv[])
{
get_files();
return 0;
}
Linux 下获取目录下的所有文件
最新推荐文章于 2022-06-13 11:05:09 发布