string函数的使用
#include<string>
#include<iostream>
using namespace std;
int main()
{
string str1 = "sdadwasd";
string str2 = "asaasdas";
if (str1 == str2)
cout << "相等" << endl;
else
cout << "不相等" << endl;
cout << str1.size() << endl;
cout << str1.length() << endl;
string str3 = "我骑着一个小毛驴", str4;
str4 = str3;
cout << str4 << endl;
int len = str3.size();
cout << len << endl;
str1.clear();
cout << str1 << endl;
if (str1.empty() == NULL)
{
cout << "字符串为空" << endl;
}
else
{
cout << "字符串不为空" << endl;
}
if (str1 == str2)
{
cout << "字符串相同" << endl;
}
char c = str3[2];
char c1 = str3.at(2);
cout << c << endl;
cout << c1 << endl;
return 0;
}