C++ 判断目录是否存在并新建目录

http://blog.csdn.net/u012005313/article/details/50688257

#include <io.h>
#include <string>
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
#include <direct.h>  
using namespace std;

int main()
{
        string  cursubdirname = "123";
    if (access(cursubdirname.c_str(), 0) == -1)
    {
        cout << cursubdirname << " is not existing" << endl;
        cout << "now make it" << endl;
#ifdef WIN32  
        int flag = _mkdir(cursubdirname.c_str());
#endif  
#ifdef linux   
        int flag = mkdir(dir.c_str(), 0777);
#endif  
        if (flag == 0)
        {
            cout << "make successfully" << endl;
        }
        else {
            cout << "make errorly" << endl;
        }
    }
}
原文地址:https://www.cnblogs.com/adong7639/p/8480301.html