【发布时间】:2016-05-27 14:33:00
【问题描述】:
我尝试在游戏中创建排行榜,但遇到了一个我无法解决的问题。
我的文本文件中有带有名称的字符串和带有分数的整数。我尝试将它们复制到ALLEGRO_USTR 以在屏幕上显示。
当我使用al_ustr_newf("%s", name1) 时,它会复制一些随机符号。
fstream file2;
file2.open("leaderboard.txt", ios_base::in);
string name1;
string name2;
string name3;
int temp_score1;
int temp_score2;
int temp_score3;
file2 >> name1 >> temp_score1;
file2 >> name2 >> temp_score2;
file2 >> name3 >> temp_score3;
ALLEGRO_USTR * ustr_name1 = NULL;
ustr_name1 = al_ustr_newf("%s", name1);
也许还有另一种方法可以在 allegro 5 中复制字符串?
【问题讨论】:
标签: c++ string stdstring allegro5