比较方式
字符串的比较是按字符串的ASCII码进行对比
字符串相等:返回0
前者大于后者:返回1
后者大于前者:返回-1
示例:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<set>
#include<map>
#define ll long long
using namespace std;
void test()
{
string str1="hello";
string str2="hello";
if(str1.compare(str2)==0)
cout<<"str1等于str2"<<endl;
}
int main()
{
test();
return 0;
}
输出结果即为cout中的内容