Chinaunix首页 | 论坛 | 博客
  • 博客访问: 267785
  • 博文数量: 113
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1044
  • 用 户 组: 普通用户
  • 注册时间: 2015-02-15 16:09
文章分类

全部博文(113)

文章存档

2016年(5)

2015年(108)

我的朋友

分类: C/C++

2015-08-28 02:08:50


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <dirent.h>
  3. int main(int argc,char** argv)
  4. {
  5. DIR *dirptr = NULL;
  6. struct dirent *entry;
  7. if(argc<2)
  8. {
  9. printf("the command need a dirname\n");
  10. return 1;
  11. }
  12. if(argc>2)
  13. {
  14. printf("the program can only deal with one dir at once\n");
  15. return 1;
  16. }
  17. if((dirptr = opendir(argv[1])) == NULL)
  18. {
  19. printf("open dir error !\n");
  20. return 1;
  21. }
  22. else
  23. {
  24. while (entry = readdir(dirptr))
  25. {
  26. printf("%s\n", entry->d_name);
  27. }
  28. closedir(dirptr);
  29. }
  30. return 0;
  31. }
gcc  opendir.c -o opendir

点击(此处)折叠或打开

  1. [root@iZ94tdwp8ysZ server]# ./opendir U-boot2013
  2. .
  3. u-boot-2013.04-rc1.tar.bz2
  4. u-boot-2013.04-rc1
  5. ..

点击(此处)折叠或打开

  1. [root@iZ94tdwp8ysZ server]# ./opendir /root/server
  2. nonblock.c
  3. opendir.c
  4. server3.c
  5. libclient.c
  6. opendir
  7. pthreadserver.c
  8. libclient
  9. selectc
  10. test_ascii
  11. demo_client.c
  12. .
  13. telnetclient
  14. server3.c.org
  15. nonblock
  16. zieckey_fifo
  17. nohup.out
  18. selects.c
  19. pthreadserver
  20. selectc.c
  21. U-boot2013
  22. telnetclient.c
  23. localhost.sql
  24. makefile
  25. demo_client
  26. telnet_server
  27. server3_nonblock.c
  28. test_ascii.c
  29. selects
  30. libserver.c
  31. make.sh
  32. telnet_server.c
  33. server3
  34. crc.c
  35. function_mysql.c
  36. ..
  37. libserver
  38. log.c



阅读(1265) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~