|
发表于 2005-12-26 09:36:53
|
显示全部楼层
man scandir:
- EXAMPLE
- /* print files in current directory in reverse order */
- #include <dirent.h>
- main(){
- struct dirent **namelist;
- int n;
- n = scandir(".", &namelist, 0, alphasort);
- if (n < 0)
- perror("scandir");
- else {
- while(n--) {
- printf("%s\n", namelist[n]->d_name);
- free(namelist[n]);
- }
- free(namelist);
- }
- }
复制代码 |
|