#include <iostream>
using namespace std;
void test01()
{
string s1 = "hello";
string s2 = "hello";
if (0 == s1.compare(s2))
{
cout << "s1 == s2" << endl;
}
else if (s1.compare(s2) > 0)
{
cout << "s1 > s2" << endl;
}
else if (s1.compare(s2) < 0)
{
cout << "s1 < s2" << endl;
}
}
int main ()
{
test01();
return 0;
}
总结:
字符串比较主要比较是否相等,比较大小没有意义