#include <stdio.h>
char* My_strcpy(char *p1,char *p2)
{
char *p3 = p1;
for(;*p2!=0;p1++,p2++)
{
*p1 = *p2;
}
return p3;
}
int My_strcmp(char *p1,char *p2)
{
for(;;p1++,p2++)
{
if(*p1-*p2 != 0)
{
return *p1-*p2;
break;
}
if(*p1 == 0 && *p2 == 0)
{
return 0;
break;
}
}
}
char * My_strcat(char *p1,char *p2)
{
char *p3 = p1;
while(p1!=0)
{
p1++;
}
for(;p2 != 0;p2++,p1++)
{
*p1 = *p2;
}
*p1 = 0;
return p3;
}
int main(int argc, const char *argv[])
{
char c[100] = "";
char *p = c;
char b[100] = "";
char *pb = b;
int len = 0;
int i = 0;
printf("请输入字符串");
scanf("%s",p);
printf("请输入字符串");
scanf("%s",pb);
for(int i=0; *(p+i) != 0;i++)
{
len++;
}
printf("my_strlen=%d\n",len);
printf("-------------------------------\n");
* My_strcpy(pb,p);
printf("%s\n",b);
int num = 0;
num = My_strcmp(pb,p);
printf("%d\n",num);*/
My_strcat(p,pb);
printf("%s\n",c);
return 0;
}