标签:c++
C++字符串常用操作
1、string的可以用相加来连接两个字符串。
#include<iostream> #include<string> using namespace std; int main() { string str; str += "hello "; str += "world !"; cout << str << endl; return 0; }
2、stringstream的运用:
#include<iostream> #include<string> #include<sstream> using namespace std; int main() { stringstream ss; ss << "hello"; //stringstream重载了“<<”运算符,可直接这么利用 ss << " "; ss << "world ! "; ss << 2014; cout << ss.str() << endl; return 0; }
标签:c++
原文地址:http://blog.csdn.net/ricardo_he/article/details/40950849