#include <sstream>
#include <string>
std::stringstream ss;
ss << "Hello, world, " << myInt << niceToSeeYouString;
std::string s = ss.str();
Take a look at this Guru Of The Week article from Herb Sutter: The String Formatters of Manor Farm
More Related Contents:
- Efficient string concatenation in C++
- Concatenate two string literals
- invalid conversion from ‘const char*’ to ‘char’
- Most optimized way of concatenation in strings
- C++ Adding String Literal to Char Literal
- How to assign string pointer value to elements of a vector using loops in C++
- c++ removing whitespace fails by using iterators
- Easiest way to convert int to string in C++
- How to convert a std::string to const char* or char*
- Rules for C++ string literals escape character
- Replace substring with another substring C++
- Differences between C++ string == and compare()?
- How to compare multiple strings inside an if statement?
- How to implode a vector of strings into a string (the elegant way)
- Fast String Hashing Algorithm with low collision rates with 32 bit integer [closed]
- Convert a string to a date in C++
- std::strings’s capacity(), reserve() & resize() functions
- splitting a string into an array in C++ without using vector
- How do I print the full value of a long string in gdb?
- comparison between string literal
- Convert std::string to QString
- How do you validate that a string is a valid IPv4 address in C++?
- “to_string” isn’t a member of “std”?
- constexpr not working if the function is declared inside class scope
- Concatenate char arrays in C++
- Reverse String C++ using char array
- Why does std::string not provide a conversion to const char*?
- C++ – repeatedly using istringstream
- Get bytes from std::string in C++
- How can you compare two character strings statically at compile time