#include#include int main() { int num = 123; std::string str = "The number is: "; std::stringstream ss; ss << num; str.append(ss.str()); std::cout << str << std::endl; return 0; }
#includeThis example is similar to the first example, but we skipped creating a stringstream object and directly appended the value of 'num' to 'str' using the append method. These examples are part of the C++ library, and are not part of a package library.#include int main() { int num = 456; std::string str = "The number is: "; std::stringstream ss; ss << num; str.append(ss.str()); std::cout << str << std::endl; return 0; }