String Library & Appending Integer :: C++
I am stuck with an intesting problem with the string library. Let say declare a string (empty). To start out, I append a statement. Afterward, I want to append an integer and end it with a char. For example:
for (int i = 0; i < 5; ++i)
strTemp += "Count down: ";
strTemp += i; // Problem!
strTemp += '...";
cout << strTemp.c_str() << endl;
The output of the code above will looking something like:
Cout download: *character that 0 represents*
Cout download: *character that 1 represents*
Cout download: *character that 2 represents*
Cout download: *character that 3 represents*
Cout download: *character that 4 represents*
The output I want is:
Cout download: 0
Cout download: 1
Cout download: 2
Cout download: 3
Cout download: 4
Is there a way to append or concatenate an integer into a string variable and have the string variable store the integer as an integer instead of the ACSII character the integer represents?
P.S. I experience the same problem with STL container. Furthermore, the problem remains even if I switch from a string to a vector<int>. It seems the two do not mix.