"JKop" <NU**@NULL.NULL> wrote in message
news:%J*******************@news.indigo.ie...
The following isn't doing what I thought it would do:
#include <iostream>
int main()
{
int k = 56;
std::string blah(" ");
blah += k;
std::cout << "\n\n" << blah << "\n\n";
}
How do I simply append a number to an std::string?
As in:
"Amount: "
becoming
Amount: 56"
You could try something like this:
#include <string>
#include <iostream>
#include <sstream>
int main()
{
std::string s("Amount:");
int tot = 42;
std::ostringstream oss;
oss << s << ' ' << tot << '\n';
std::cout << oss.str();
}
Regards,
Sumit.
--
Sumit Rajan <sumitrajan AT alexandria DOT cc>