/**原型:int strcmp(const char *s1,const char * s2);*用法:#include *功能:比较字符串s1和s2。*说明:* 当s1 <0* 当s1=s2时,返回值=0* 当s1>s2时,返回值>0*编程实现strcmp*/#include #include int _strcmp(const char * s,const char * t){ assert((s != NULL)&&(t != NULL)); while(*s && *t && *s==*t) { s++; t++; } return *s-*t;}int main(){ char str1[] = "apPle"; char *str2 = "apple"; int flag = _strcmp(str1,str2); if(flag < 0) printf("%s is less than %s\n",str1,str2); else if(flag == 0) printf("%s is equal %s\n",str1,str2); else printf("%s is larger than %s\n",str1,str2); getchar(); return 0;}