注意:
string s="one";
cout<<s[2]<<endl;
输出结果为 e;
string s[3]={"one","two","three"};
cout<<s[2]<<endl;
输出结果为 three;
字符串连接:
string a="one";
string b="two";
cout<<a+b<<endl;
输出结果为 onetwo
字符串比较:
string a="aaabbbcccd";
string b="bbbaaaeeea";
for(int i=0;i<10;i++)
{
if(a[i]>b[i])
cout<<"1"<<endl;
else
cout<<"2"<<endl;
}
输出结果:2221112221
字符串长度:
string a="12345";
cout<<a.size()<<endl;
输出结果为 5;