#include <stdio.h>
#if 0
#include <string.h>
#else
int strcmp(const char *a, const char *b)
{
int i = 0;
while (a[i] != '\0' && a[i] == b[i])
++i;
return a[i] - b[i];
}
#endif
int main(void)
{
char a[2] = {-2, '\0'};
char b[] = {-3, '\0'};
int ret = strcmp(a, b);
printf("ret: %d\n", ret);
return 0;
}
strcmp函数实现
最新推荐文章于 2024-08-04 00:14:01 发布