One solution is to use stringstreams:
#include<sstream>
for (int i=0; i<23; i++)
{
stringstream left, right;
left << "C:/x/left" << i << ".bmp";
right << "C:/x/left" << i << ".bmp";
imagelist.push_back(left.str());
imagelist.push_back(right.str());
}
stringstream
is not the faster in performance solution, but is easy to understand and very flexible.
Another option is to use itoa
and sprintf
, if you feel at home with c style printing. However, I have heard that itoa
is not very portable function.