str_c无法合并 r语言,'str'中的成员'c_str'的请求,这是非类

main.cpp:561:80: error: request for member ‘c_str’ in ‘str’, which is of non-class type ‘std::string [10] {aka std::basic_string [10]}’

displayFont.showHighscore[i] = TTF_RenderText_Solid(displayFont.menuFont,str.c_str(), displayFont.colorText);

根据这个函数,它显示了一个从成员类中取回的数据的排名。另外这个使用来自另一个类(displayFont)的ttf内容。当我编译这个,说一个错误。我离开的代码:

void showHighscore() {

displayFont.menuFont = TTF_OpenFont("fonts/Lanehum.ttf",25);

displayFont.colorText = { 255, 255, 255 }; // Add content

stringstream texting[10]; // Variables

string str[10];

SDL_Rect posHighscore[10];

for (int i = 0; i < 10; i++) {

texting[i] << i << "# - " << dat.topScore[i];

str[i] = texting[i].str();

displayFont.showHighscore[i] = TTF_RenderText_Solid(displayFont.menuFont,str.c_str(), displayFont.colorText); // OUTPUTTING ERROR :/

posHighscore[i].x = 50;

posHighscore[i].y = 50 * (i+1);

}

while (true) {

for (int i = 0; i < 10 ; i++) {

SDL_BlitSurface(displayFont.showHighscore[i],NULL,screen,&posHighscore[i]);

} // Show the rendered text

SDL_Flip(screen);

SDL_Delay(5000);

break;

}

}

+0

答案很明显,我不能把它。只要看看你如何使用'str'和'texting'就行了......(编辑:答案抛出......) –

+0

尝试'str [i] .c_str()'? –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值