I'm trying to increment the name of the file based on the number associated with the filename. If I make the variable postFix an int type, it gives an error (understandably) since I can't concatenate an int to a string type.
In that case how do I increment string variable?
for (int i = 0; i <= 10; i++)
{
std::string postFix = "1"; // int postFix = 1 gives an error
std::cout << (std::string("Image" + postFix + std::string(".png")));
}
You can use
std::to_string
to create astd::string
from yourint
value.Although in this case you might as well just use the stream
operator<<