ashin_creeper的博客通过本文主要向大家介绍了c语言等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
#include <iostream>
using namespace std;
int strcmp(const char *a,const char *b){
int cmp=0;
while(!(cmp=*(unsigned char*)a-*(unsigned char*)b) && *a && *b){
++a;
++b;
}
if(cmp<0)
cmp=-1;
else if(cmp>0)
cmp=1;
return cmp;
}
int main(){
char c1[]="12345678";
char c2[]="135792468";
cout << strcmp(c1,c2) << endl;
return 0;
}