Linux下C语言获取目录中的文件列表
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
int main(){
DIR *dir;
struct dirent *ptr;
dir = opendir("/home/zhangyang/kmeans");
while((ptr = readdir(dir)) != NULL)
printf("d_name: %s\n", ptr->d_name);
closedir(dir);
return 0;
}

浙公网安备 33010602011771号