码迷,mamicode.com
首页 > 编程语言 > 详细

c++ linux 遍历文件夹下的文件

时间:2019-04-02 20:57:39      阅读:417      评论:0      收藏:0      [点我收藏+]

标签:file   lis   namespace   数据   遍历文件   fstream   read   code   close   

#include #include "fstream" #include #include #include #include using namespace std; string key="aabbccdd1122334455absacsafasfasvsapocasppf123oawirpw"; int lenOfAllKey=256; int main(){ DIR * dir; struct dirent * ptr; char file_list[100][40]; int i=0; char srcFile1[1][100]; printf("111\n"); string rootdirPath = "/home/jyh/code/rc4加密/password/"; string string x,dirPath; dir = opendir((char *)rootdirPath.c_str()); //打开一个目录 while((ptr = readdir(dir)) != NULL) //循环读取目录数据 { printf("d_name : %s\n", ptr->d_name); //输出文件名 x=ptr->d_name; dirPath = rootdirPath + x; //printf("d_name : %s\n", dirPath.c_str()); //输出文件绝对路径 // x = dirPath.c_str(); strcpy(srcFile1[i],dirPath.c_str()); //存储到数组 if ( ++i>=100 ) break; } printf("111\n"); closedir(dir);//关闭目录指针 }

c++ linux 遍历文件夹下的文件

标签:file   lis   namespace   数据   遍历文件   fstream   read   code   close   

原文地址:https://www.cnblogs.com/nowheretrix/p/10644994.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!