//模拟字符串函数strcmp #define _CRT_SECURE_NO_WARNINGS 1 #includeint MyStrcmp(const char* s1, const char* s2) { while (*s1 == *s2 && *s1 != ' ') { 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; }



