#include <iostream>
#include <Windows.h>
#include <string>
#include <stdio.h>
/*编写一个程序,链接两个字符串字面常量,将结果保存在一个动态分配的 char
数组中。重写这个程序,连接两个标准 string 对象。*/
using namespace std;
int main(void){
const char *a1 = "ab";
const char *a2 = "cd";
char *p = new char[64];
strcpy(p, a1);//拷贝
strcat(p,a2);//连接
cout << p<< endl;
delete[] p;
string str1 ="";
string str2 = "";
string *str = new string[1024];
cout << "请输入第一个字符串:";
cin >> str1;
cout << "请输入第二个字符串:";
cin >> str2;
*str = str1 +str2;
cout << *str << endl;
delete[] str;
system("pause");
return 0;
}