[英]No suitable conversion function from std string to const char * exists
I'm using a pre-built library and in order for me to load a texture and display it I have to use this code. 我正在使用一个预建的库,为了让我加载纹理并显示它,我必须使用此代码。 I'm looking to load multiple files and store them as a
struct
in an array so they can be called and displayed. 我希望加载多个文件并将它们作为
struct
存储在数组中,以便可以调用和显示它们。 I keep getting this error: 我不断收到此错误:
No suitable conversion function from
std
string to const char * exists不存在从
std
字符串到const char *的合适转换函数
when trying to load in the section below. 尝试在以下部分加载时。
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());
}
The problem is most probably with the way you call Load
, a fix is to use fullfileName.c_str()
: 问题很可能与您调用
Load
的方式有关,一种解决方法是使用fullfileName.c_str()
:
cutSceneMain[i]->texture->Load(fullfileName.c_str(), false);
^^^^^^^
Load
requires const char*
Load
需要const char*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.