代码之家  ›  专栏  ›  技术社区  ›  Malay Joshi

C++如何创建文件夹

  •  -1
  • Malay Joshi  · 技术社区  · 2 年前

    我的当前代码

    #include<windows.h>
    #include<fstream>
    #include<direct.h>
    #include<conio.h>
    #include<sys/stat.h>
    #include<filesystem>
    
    int main(){
        int choice;
        std::string folder_n;
    
        std::cin >> choice;
    
        if(choice == 2){
            std::cout << "Enter folder name" << std::endl;
            std::cin >> folder_n;
    
            filesystem::create_directory(folder_n);
            std::cout << "created folder named " << folder_n << std::endl ;
                
        }
    
        return 0;
    }
    

    我的问题--> 错误:“文件系统”尚未声明 有人能告诉我为什么会出现这个错误,以及如何修复它吗

    Note : 1. filesystem is included in my c++ version because intellisense is showing filesystem
           2. I am using MinGw 
           3. My MinGW version is 9.2.0```
    
    0 回复  |  直到 2 年前
        1
  •  0
  •   XmanJob    2 年前

    Create\u目录仅适用于c++17。

    在编译时,请尝试g++-std=c++17文件。cpp。

    这是所有文件系统功能的站点 here