Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7491
  • 博文数量: 14
  • 博客积分: 250
  • 博客等级: 二等列兵
  • 技术积分: 95
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-13 01:08
文章分类
文章存档

2011年(14)

我的朋友
最近访客

分类: 网络与安全

2011-01-13 01:58:25


  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dirent.h>
  4. #include <sys/types.h>

  5. #define PATHSTR "/etc"
  6. int main()
  7. {
  8.         DIR *dp;
  9.         struct dirent *res;
  10.         dp = opendir(PATHSTR);
  11.         if((dp == NULL))
  12.         {
  13.                 perror("opendir()error");
  14.                 exit(1);
  15.         }
  16.         while((res = readdir(dp)) != NULL)
  17.         {
  18.                 puts(res->d_name);
  19.         }
  20.         closedir(dp);
  21.         return 0;
  22. }
  23. ~
  24. ~
  25. ~
阅读(169) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~