用指针合并两个字符串(C语言)

2024-12-02 12:36:53
推荐回答(1个)
回答(1):

#include

void fun(char* dest, char* s1, char* s2)
{
while (*dest++=*s1++);
dest--;
while (*dest++=*s2++);
}
main()
{
char dest[256];
char* s1="Happy ";
char* s2="New Year";
fun(dest,s1,s2);
printf("%s\n",dest);
}