#include<iostream.h>
#include<stdio.h>#include<string.h>
int my_strcmp(const char *dest,const char *src)
{
if((*dest == 0) && (*src == 0))
return 1;
while((*dest != 0) && (*src != 0))
{
if(*dest != *src)
return 0;
dest++;
src++;
}
if((*dest == 0) || (*src == 0)) //至少有一个为零
{
if((*dest == 0) && (*src == 0)) //同时为零 ,比较完毕
return 1;
return 0;
}
return 1;
}`
int main()
{
char *s = "abcde";
char *t = "abc";
char *r = "";
cout<<my_strcmp(s,r)<<endl;
cout<<my_strcmp(s,t)<<endl;
cout<<my_strcmp(t,r)<<endl;
return 0;
}