#include<stdio.h>
#include<string.h>
int mycmp(const char* s1, const char* s2)
{
/*int idx = 0;
while (s1[idx] == '\0'&& s1[idx]==s2[idx]) {
if (s1[idx] != s2[idx]) {
break;
}
else if (s1[idx] == '\0') {
break;
}
idx++;
}
return *s1 - *s2;???????*/
while (*s1 == *s2 && *s1 != '\0') {
s1++;
s2++;
}
return *s1 - *s2;
}
int main(int argc, char const* argv[])
{
char s1[] = "abc";
char s2[] = "acd";
printf("%d\n", mycmp(s1, s2));
return 0;
}
//if (strcmp(s1,s2)==0){}
strcmp
最新推荐文章于 2024-07-18 16:42:53 发布