临时


#include <dirent.h>
#include <stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

int main()
{
    string a = "/root/";
    string b;
    getline(cin,b);
    string c = a + b;
    const char* d = c.c_str();
    DIR *dirp; 
    struct dirent *dp;
    dirp = opendir(d); //打开目录指针
    while ((dp = readdir(dirp)) != NULL) { //通过目录指针读目录
        printf("%s\n", dp->d_name );
    }      
    (void) closedir(dirp); //关闭目录
    return 0;
}

 

posted @ 2017-05-23 15:46  花园小花匠  阅读(148)  评论(0编辑  收藏  举报