#include <sstream> // ... std::stringstream ss; //put arbitrary formatted data into the stream ss << 4.5 << ", " << 4 << " whatever"; //convert the stream buffer into a string std::string str = ss.str();