一:
#include<stdio.h>
#include<stdlib.h>
char* mycat(char *a,char *b)
{
char* ret=a;
while(*a!='\0')
{
*a++;
}
while(*b!='\0')
{
*a=*b;
*a++;
*b++;
}
*a='\0';
return ret;
}
int main()
{
char s1[20]="abcd";
char s2[20]="Abcde";
printf("%s\n",mycat(s1,s2));
return 0;
}
二:
#include<stdio.h>
#include<stdlib.h>
char* mycat(char *a,char *b)
{
char* ret=a;
while(*a!='\0')
{
a++;
}
while(*b!='\0')
{
*a=*b;
*a++;
*b++;
}
*a='\0';
return ret;
}
int main()
{
char s1[20]="abcd";
char s2[20]="Abcde";
printf("%s\n",mycat(s1,s2));
return 0;
}
慕用4063026
慕沐4449596
相关分类