方法(1)
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main(void) {
string p1 = "我是";
string p2 = "大哥哥";
int count = 0;
int a = 64;
char* a1 = new char[64];
if (!p1.empty()) {
for (int i = 0; i < size(p1); i++){
*(a1 + count) = p1[i];
count++;
}
}
if (!p2.empty()) {//判断是否为空
for (int i = 0; i < size(p2); i++) {
*(a1 + count) = p2[i];
count++;
}
}
*(a1 + count) = '\0';
cout << a1 << endl;
delete[]a1;
system("pause");
return 0;
}