#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
void test01()
{
string str1 = "abadef";
string str2 = "abcdef";
int com = str1.compare(str2);
if (com == 0)
{
cout << "两个字符串相等" << endl;
}
else if (com > 0 || com < 0)
{
cout << "两个字符串不相等" << endl;
}
}
int main()
{
test01();
system("pause");
return 0;
}
(3)string-字符串比较
最新推荐文章于 2024-06-23 11:08:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)