天天看點

Linux 下周遊所有目錄下的檔案

Linux 下周遊所有目錄下的檔案

//#include<dirent.h> 
DIR* dir = opendir("/home/liu/Desktop/C++/test7/txt");
    dirent* p = NULL;
    while((p = readdir(dir))!=NULL){
        if (p->d_name[0] != '.'){
            string name = "/home/liu/Desktop/C++/test7/txt/"+string(p->d_name);
            cout<<name<<endl;
        }
    }
    closedir(dir);
           

繼續閱讀