void _strcat(char *dest,char *sorc)
{
while(*dest) dest++; //首先目标字符串指针指到末尾
while(*dest++=*sorc ++); //赋值...直到sorc为空
}
#include <stdio.h>
#include <stdlib.h>
char* mystrcat(char* s1, char* s2)
{
char* tmp1 = s1;
char* tmp2 = s2;
for (; *tmp1; ++tmp1){}
while ( (*tmp1++ = *tmp2++) ){}
return s1;
}
int main(void)
{
char sz1[100] = "abc123";
char sz2[] = "okok456";
mystrcat(sz1, sz2);
printf("sz1=%s\n", sz1);
return 0;
}
#include
#include
char* mystrcat(char* s1, char* s2)
{
char* tmp1 = s1;
char* tmp2 = s2;
for (; *tmp1; ++tmp1){}
while ( (*tmp1++ = *tmp2++) ){}
return s1;
}
int main(void)
{
char sz1[100] = "abc123";
char sz2[] = "okok456";
mystrcat(sz1, sz2);
printf("sz1=%s\n", sz1);
return 0;
}
strcat