1、c++中字符串的操作头文件 #include <string> 2、getline 3、find #include <iostream> #include <string> //c++中字符串操作的头文件! using namespace std; int main() { string str; while(getline(cin, str)) //getlin 函数 { int start = str.find("you"); while(start != string::npos) //这里要注意 { str.replace(start, 3, "we"); //替换字符串的函数 start = str.find("you", start+2); //找相应字符串的函数 } cout << str << endl; } return 0; }