简体   繁体   English

C ++ Wierd在调用的函数上崩溃

[英]C++ Wierd crash on function called

I checked the return of GetCharacterRankINT() and it is returning the right value (1). 我检查了GetCharacterRankINT()返回值,并返回了正确的值(1)。 When I tested the query with the rankNum 1 I got the right result, but whenever I try to use GetCharacterRankSTR() it crashes with the following crash dump: http://fbe.am/rwl (Password: stackoverflow). 当我用rankNum 1测试查询时,我得到了正确的结果,但是每当我尝试使用GetCharacterRankSTR()它就会由于以下崩溃转储而崩溃: http : GetCharacterRankSTR() (密码:stackoverflow)。 I tried to set the type of the function from string to std::string and it still didn't work. 我试图将函数的类型从字符串设置为std :: string,但仍然无法正常工作。 The MySQL table has 8 columns, or so the field has 8 entries. MySQL表有8列,因此该字段有8个条目。 Therefore the error is not related to the amount of fields. 因此,该错误与字段的数量无关。

string Player::GetCharacterRankSTR()
{
    QueryResult* res = CharacterDatabase.Query("SELECT * FROM ars_ranks WHERE rankNum = %u LIMIT 1;", GetCharacterRankINT());
    if (!res)
    {
        return "Error";
    }
    else
    {
        Field* fld = res->Fetch();
        return fld[3].GetString();
    }
}

My question is: What am I doing wrong in the function so that it crashes? 我的问题是:我在函数中做错了什么,使其崩溃了?

经过一些测试,我找到了解决方法...我只需要从字符串更改为const char *。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM