c++ string比较大小

来源:互联网 发布:java 数组转字符串 编辑:程序博客网 时间:2024/06/05 12:42

很简单,像整型一样直接比较

例如:

#include<iostream>#include<string>using namespace std;int main(){    string a="abcd",b="dcba";    if(a>b) cout<<1<<endl;    else cout<<0<<endl;    return 0;}

输出 0

就是这么简单!!!

原创粉丝点击