//模拟字符串函数strcmp
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int MyStrcmp(const char* s1, const char* s2)
{
while (*s1 == *s2 && *s1 != '\0')
{
s1++;
s2++;
}
return *s1 - *s2;
}
int main()
{
char* p1 = "abcd";
char* p2 = "abco";
int ret = MyStrcmp(p1, p2);
if (ret > 0)
{
printf("p1 > p2");
}
else if (ret < 0)
{
printf("p1 < p2");
}
else
{
printf("p1 = p2");
}
return 0;
}
12-06
333
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交