用C语言读入目录

1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <dirent.h>
4
5 int main()
6 {
7 struct dirent *dp;
8 DIR *dfd = opendir(".");
9 if (dfd != NULL) {
10 while((dp = readdir(dfd)) != NULL)
11 printf("%s\n", dp->d_name);
12 closedir(dfd);
13 }
14 getchar();
15 return 0;
16 }

原文地址:https://www.cnblogs.com/shenfei2031/p/2017512.html