函数输入: 两个源字符串的指针,目的字符串的指针。
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
using namespace std;
char *str(char *p1, char *p2){
char *p = p1;
while (*p1++);
p1--;
while (*p1++ = *p2++);
return p;
}
int main(void) {
char s1[100] = "我爱", s2[100] = "编程";
printf("拼接后的字符串为:");
printf("%s\n", str(s1, s2));
system("pause");
return 0;
}