Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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字符串到const char*的适当转换函数_C++_String_C++11_Char - Fatal编程技术网

C++ 不存在从std字符串到const char*的适当转换函数

C++ 不存在从std字符串到const char*的适当转换函数,c++,string,c++11,char,C++,String,C++11,Char,我正在使用一个预构建的库,为了加载纹理并显示它,我必须使用以下代码。我希望加载多个文件并将它们作为结构存储在数组中,以便调用和显示它们。我不断地发现这个错误: 不存在从std字符串到const char*的适当转换函数 在下面的部分中尝试加载时 for (int i=0; i<CUTSCENE; i++) { stringstream s; int fileNum = i+1; string FirstPart = "Textures/GameVideos/Gam

我正在使用一个预构建的库,为了加载纹理并显示它,我必须使用以下代码。我希望加载多个文件并将它们作为结构存储在数组中,以便调用和显示它们。我不断地发现这个错误:

不存在从std字符串到const char*的适当转换函数

在下面的部分中尝试加载时

for (int i=0; i<CUTSCENE; i++)
{
    stringstream s;
    int fileNum = i+1;

    string FirstPart = "Textures/GameVideos/Game (";
    string LastPart = ").png";

    s << FirstPart << fileNum << LastPart << endl;
    string fullfileName;
    s >> fullfileName;

    cutSceneMain[i]->texture = new Texture2D();
    cutSceneMain[i]->texture->Load(fullfileName, false);
    cutSceneMain[i]->sourceRect = new Rect(0.0f, 0.0f, 700, 700);
    cutSceneMain[i]->position = new Vector2(0.0f, 0.0f());
}

问题很可能与调用Load的方式有关,修复方法是使用fullfileName.c_str:


Load需要const char*

问题很可能在于调用Load的方式,解决方法是使用fullfileName.c_str:

加载需要常量字符*

cutSceneMain[i]->texture->Load(fullfileName.c_str(), false);
                                            ^^^^^^^