char buffer; std::snprintf(buffer, 100, "Hi, I am %d years old.", x); std::string my_string(buffer);That's kind of ugly, because it requires you to come up with an upper bound for the space needed for the string, and because it formats the string in one buffer and then you need to copy it if you want it as a string. But if you need to do any formatting of the numbers, it's much easier to use the printf family of functions than <iomanip>. You can also pick different formatting strings dynamically, which is much more flexible than the other methods.
Another interesting alternative for formatting is Boost Format..