#include <iostream>
using namespace std;
#define MIN(a,b) (a<b?a:b)
int strCmp(const char * str1, const char *str2){
int minLen=MIN(strlen(str1),strlen(str2));
for(int i=0;i<=minLen;i++){
if(str1[i]>str2[i]) return 1;
else if(str1[i]<str2[i]) return -1;
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[]){
char a1[]="abSasasdcd";
char a2[]="Aabgwacdx";
cout<<strCmp(a1,a2)<<endl;
return 0;
}
【C++程序设计】补6.3 strcmp实现
最新推荐文章于 2021-05-16 11:37:00 发布