#include #include #include using namespace std; int main() { string q; int a = 3; int b = 6; ostringstream s; s << a << " hi " << b; q = s.str(); const char *buf = q.c_str(); cout << buf << endl; char buf2[256]; //%d integers //%c characters //%s is cstrings (never use "string" here, only cstrings) //%s is used with strings with the c_str() //%f is floats sprintf(buf2, "%d hi %d", a,b); cout << buf2 << endl; }