#include<iostream>
#include<Windows.h>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
string s1 = "hello,";
string s2 = "world!";
string s3="";
s3 = s1 + s2;
char *cp = new char[s3.length()];
for(int i=0;i!=s3.length();i++){
*(cp+i)=s3[i];
}
for(int i=0;i!=s3.length();i++){
cout<<cp[i];
}
system("pause");
return 0;
}
连接两个标准 string 对象,,将结果保存在一个动态分配的 char 数组中
最新推荐文章于 2023-03-17 14:28:00 发布