qua*_*tic 0 c++ variables filenames
我正在制作一个使用"graphics.h"标题的C++程序/游戏,我正在尝试创建一个带有图块的地图.有66个瓷砖,每个文件名都不同.我想要显示它们而不必一遍又一遍地写出几乎相同的线条.
这是我到目前为止(伪代码):
filename = a + number + b;
readimagefile (filename, left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
其中a是"bg(",后跟1到66之间的数字,然后是b,这是".bmp".我希望文件名是这样的:"bg(number).bmp".但是,我上面的内容显然是错误的语法.
我该怎么做呢?提前感谢您的任何答案.
std::stringstream str;
str << a << number << b << ".bmp";
Run Code Online (Sandbox Code Playgroud)
然后str.str()返回一个c ++ std :: string并str.str().c_str()返回一个'c'类型的字符串