#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str("hello word hello my dear master!");
string str_1,str_2,str_3;
//cout<<"请输入一段字符"<<endl;
//cin>>str;
//提取字串
cout<<"它的一段子串是:"<<endl;
str_1=str.substr(1,3);
str_2=str.substr(2,3);
cout<<"str_1 = "<<str_1<<" "<<"str_2 = "<<str_2<<endl;
// 比较字符串
cout<<"str_1与str_2进行比较"<<endl;
if( str_1 > str_2)
cout<<"str_1 > str_2"<<endl;
else
cout<<"str_1 <= str_2"<<endl;
//添加字符串
cout<<"请输入你要添加的字符串:"<<endl;
char temp[200 ]={'\0'};
cin.getline(temp,200);
cout<<"添加后的结果:str = "<<str.append(temp)<<endl;
//搜索字符串
cout<<"请输入你要搜索的字符串:"<<endl;
cin.getline(temp,200);
if(str.find(temp)!=-1)
{
cout<<"存在!"<<endl;
}
else
{
cout<<"不存在!"<<endl;
}
return 0;
}