#include
void strcpy(char *s1, char *s2)
{
if(s1==NULL || s2==NULL) return;
while(*s2 != '\0') *s1 ++ = *s2++;
*s1 = '\0';
}
void strcat(char *s1, char *s2)
{
if(s1==NULL || s2==NULL) return;
while(*s1 != '\0') s1 ++;
while(*s2 != '\0') *s1 ++ = *s2++;
*s1 = '\0';
}
int main(void)
{
char s1[100] = "abcd";
char s2[100] = "1234";
char s3[100] = "UVWXYZ";
strcat(s1, s2);
strcpy(s2, s3);
printf("%s\n", s1);
printf("%s\n", s2);
return 0;
}
char *strcat(char *source,char *destin)
{
while(*source);
do{
*source++=*destin;
}while(*destin++);
}
char *strcpy(char *str1,char *str2)
{
char *p,*q;
if(str1==null and str2==null)return null;
p=str1;q=str2;
while(*p!='\0' &&*q!='\0'){*p++=*q++;}
return str1;
}
百度百科中有