c++ linux 遍歷文件夾下的文件


#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);//關閉目錄指針 }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM