std::ostrstream MYOUT(str, sizeof(str));
拼接字符串
1 #include <iostream> 2 #include <strstream> 3 4 void main() 5 { 6 char str[100] = { 0 }; 7 std::ostrstream MYOUT(str, sizeof(str)); 8 9 char str1[100] = " world"; 10 11 MYOUT << "hello" << str1 << std::endl;//拼接字符串 12 13 std::cout << MYOUT.str() << std::endl;//打印 14 15 std::cout << str << std::endl;//打印 16 17 system("pause"); 18 }