linux c/c++ 读取指定目录下的文件名
2016-11-26 20:17
197 查看
#include <dirent.h> #include <stdio.h> /*struct dirent { long d_ino; // inode number 索引节点号 off_t d_off; // offset to this dirent 在目录文件中的偏移 unsigned short d_reclen; // length of this d_name 文件名长 unsigned char d_type; // the type of d_name 文件类型 char d_name [NAME_MAX+1]; // file name (null-terminated) 文件名,最长255字符 } 其中d_type表明该文件的类型:文件(8)、目录(4)、链接文件(10)等 */ int main(){ DIR *directory_pointer; struct dirent *entry; if((directory_pointer=opendir("/home/libin/桌面"))==NULL){ printf("Error open\n"); return ; } else { while((entry=readdir(directory_pointer))!=NULL){ if(entry->d_name[0]=='.') continue; printf("%s\n",entry->d_name); } } return 0; }
相关文章推荐
- Linux/Unix下读取指定目录下的所有文件名
- linux C++ & C 读取指定目录下的指定后缀名,去除处扩展名获取名字存至数组
- Linux/Unix下读取指定目录下的所有文件名
- linux下读取指定目录下的文件名,并进行排序
- Linux输入文件名从FTP 指定目录下载 文件
- asp读取指定目录下的文件名
- linux下编写shell获取指定目录下的文件名
- window下获取指定目录下面的所有文件名 c/c++
- 指定文件名读取WEB-INFO目录下properties配置(windows平台)
- 分享下java 读取目录及子目录下指定文件名的路径 并放到一个List数组里面返回遍历和写到文件里
- C++实现Linux和Windows下遍历指定目录下的文件
- Java读取指定目录下的所有文件名
- c++读取目录下所有文件名
- php读取指定目录文件夹下所有文件名
- 在linux下递归获取指定目录下指定扩展名的文件名列表
- C++读取某一目录下的所有文件名
- cocos2d-x:读取指定目录下的文件名+解决中文乱码(win32下有效)
- window下获取指定目录下面的所有文件名 c/c++
- 分享下java 读取目录及子目录下指定文件名的路径 并放到一个List数组里面返回遍历和写
- 在windows 、linux下读取目录下所有文件名