简体   繁体   English

不存在从标准字符串到const char *的合适转换函数

[英]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.

相关问题 不存在从“std::string”到“const char *”的合适转换函数 - No suitable conversion function from “std::string” to “const char *” exists c++ 不存在从“std::string”到“const char*”的合适转换函数 - c++ no suitable conversion function from "std::string" to "const char*" exists 如何修复“没有合适的转换函数从”String“到”const char *“存在”? - How to fix “no suitable conversion function from ”String“ to ”const char *“ exists”? 不存在从“ std :: string”到“ char”的适当转换 - no suitable conversion from “std::string” to “char” exists 从“ const std :: string”到“ time_t”的转换函数不存在 - No suitable conversion function from “const std::string” to “time_t” exists IntelliSense:不存在从“ std :: string”到“ char”的合适转换函数,那么我该如何处理? - IntelliSense: no suitable conversion function from “std::string” to “char” exists so how do i go about this? 从“ std :: string”到“ PVOID”的转换功能不存在 - no suitable conversion function from “std::string” to “PVOID” exists 6 IntelliSense:不存在从“ std :: string”到“ int”的合适转换函数 - 6 IntelliSense: no suitable conversion function from “std::string” to “int” exists 从const char *转换为const std :: string& - Conversion from const char * to const std::string & 我收到错误消息:std :: basic_istream没有合适的转换函数 <char, std::char_traits<char> &gt;到char存在 - I'm getting the error: no suitable conversion function from std::basic_istream<char, std::char_traits<char>> to char exists
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM