Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ “没有合适的转换函数”;std::string";至;常量字符*”;存在c++;_C++ - Fatal编程技术网

C++ “没有合适的转换函数”;std::string";至;常量字符*”;存在c++;

C++ “没有合适的转换函数”;std::string";至;常量字符*”;存在c++;,c++,C++,这是一个版本号目录的简单程序。无法编译,出现以下错误: 不存在从“std::string”到“const char*”的适当转换函数 #包括 #包括 #包括 使用名称空间std; int main(){ int max=10,每日补丁=0,每月补丁=0,每年补丁; cout>年度斑块; for(int i=yearly_patch;imkdir()来自POSIX API,它需要C语言,因此它需要C样式的字符串。因此使用mkdir(dir.C_str()); 如果你想使用C++ API,你有一个最

这是一个版本号目录的简单程序。无法编译,出现以下错误:

不存在从“std::string”到“const char*”的适当转换函数

#包括
#包括
#包括
使用名称空间std;
int main(){
int max=10,每日补丁=0,每月补丁=0,每年补丁;
cout>年度斑块;
for(int i=yearly_patch;i
mkdir()
来自POSIX API,它需要C语言,因此它需要C样式的字符串。因此使用
mkdir(dir.C_str());


如果你想使用C++ API,你有一个最近的编译器,你可以使用.< /P>一个变量定义,一行。那更好。<代码> MKDIR(DIR);< /代码> = >代码> MKDIR(dir CyScript());请不要大声喊我们(没有满大写的句子,尤其是没有粗体字)。为什么C风格?头文件错误?MKDIR是来自C API的。所以它不理解C++对象。如果你想要C++ API,请使用

#include <iostream>
#include <stdio.h>
#include <io.h>

using namespace std;

int main() {
    int max = 10, daily_patch = 0, monthly_patch = 0, yearly_patch;

    cout << " Enter the yearly_patch Number : ";
    cin >> yearly_patch;

    for (int i = yearly_patch; i <= yearly_patch; i++) {
        for (int j = 0; j < max; j++) {
            for (int k = 0; k < max; k++) {
                string str1 = to_string(i);
                string str2 = to_string(j);
                string str3 = to_string(k)
                string dot = ".";
                string dir = str1 + dot + str2 + dot + str3;
                
                mkdir(dir);
            }
        }
    }
}