标签:include c语言 return china strcmp
#include <stdio.h>
#include <assert.h>
int my_strcmp(const char * str1, char * str2)
{
int ret = 0;
assert(str1);
assert(str2);
while ((*str1 == *str2) && *str1&&*str2)
{
str1++;
str2++;
while (!(*str1&&*str2)) //判断str1和str是否同时指向 \0
return 1; //相等返回1
}
return -1; //不相等返回-1
}
void main()
{
char str1[100] = {"i love"};
char str2[50] = {"China "};
printf("%d\n",my_strcmp(str1,str2));
}本文出自 “Vs吕小布” 博客,谢绝转载!
标签:include c语言 return china strcmp
原文地址:http://survive.blog.51cto.com/10728490/1712923