本文共 575 字,大约阅读时间需要 1 分钟。
#includeint strcmp(char *source, char *dest){ int m,n,i,flag; m = strlen(source); n = strlen(dest); if(m!=n) flag = -1; if(source==NULL&&dest==NULL) { flag = 0; } if(source!=NULL&&dest!=NULL) { while(*source==*dest&&*source!='\0') { source++;dest++; } if(*dest=='\0') flag = 0; else flag = -1; } else flag = -1; return flag;}void main(){ int i; char *str = "hello"; char *str1 = "hello"; i = strcmp(str,str1); printf("%d",i);}
转载地址:http://flkhj.baihongyu.com/