我可以格式化 anInt
以显示带有前导零的数字,但我不知道如何将Int
带有零的 an 保存到 a string
。
"..0001" "..0002" ... "..0059"
原因:加载以etc结尾的图像文件。
我有这个,但它不起作用:
int a;
for(int i = 1; i < imgArraySize + 1; i++)
{
cout << setw(4) << setfill('0') << i << '\n';
cin >> a;
string aValue = to_string(a);
imageNames.push_back(string("test_images" + aValue + ".jpg"));
}