创建目录结构

创建目录:

int main() {
    //创建目录
    char* pps_path = (char*)malloc(100);
    char* real_path = "data/E8/asop/qnx_ap";
    int len = strlen(real_path);
    memcpy(pps_path, real_path, len);
    for(int i = 0; i < len; i++){
        if(pps_path[i] == '/') {
            pps_path[i] = 0;
            std::cout << pps_path << std::endl;
            //逐级创建目录
            (void)mkdir(pps_path, 0777);
            pps_path[i] = '/';

        }
    }
    return 0;
}

输出结果:

data
data/E8
data/E8/asop

你可能感兴趣的:(算法)