写一个程序实现功能:将两个字符串合并为一个字符串并且输出,用指针实现。
#include<iostream>
#include<string>
using namespace std;
void main(){
char s1[100], s2[100];
cout << "请输入两个字符串:" << endl;
cin >> s1 >> s2;
cout << s1 << " " << s2 << endl;
char *p1, *p2;
p1 = s1;
p2 = s2;
while (*p1)p1++;
while (*p2){
*p1 = *p2;
p1++;
p2++;
}
*p1 = '\0';
cout << "合并后的字符串为:" << endl;
cout << s1 << endl;
system("pause");
}