Concatenating an integer to a string

c++

Solution

The c++ way (pre-c++11) would be:

#include <sstream>
...
ostringstream convert;
convert << "G:/OpenCV/Results/Image" << i << ".jpg";
cvSaveImage(convert.str().c_str(), img2);
i++;

Problem

I am trying to save a sequence of images in visual studio 2008,all with the prefix of "Image". the only differentiating factor should be their number. for example if I am gonna save 10 images then the situation should be ``` i=1; while(i<10) { cvSaveImage("G:/OpenCV/Results/Imagei.jpg",img2); i++ //"i" is gonna be different every time } ``` so I need to concatenete the integer with the string... looking forward to the answer...

Original source

Related problems