/*
*编写程序连接两个C风格字符串字面值,把结果存储在一个C风格字符串中。
*然后再编写程序连接两个string类型字符串,这两个string类型的字符串
*与前面的C风格字符串字面值具有相同的内容。
*/#include <iostream>#include <cstring>#include <string>usingnamespacestd;
int main()
{
constchar *str1 = "who and who ";
constchar *str2 = "will get together !";
char *str3;
string str5, str6, str7;
str3 = newchar[strlen(str1) +strlen(str2) +1];
strcpy(str3,str1);
strcat(str3,str2);
for(int i = 0; i != strlen(str3); ++i)
cout << *(str3 + i);
cout << endl;
str5 = "who and who ";
str6 = "will get together !";
str7 = str5 + str6;
cout << str7;
delete [] str3;
str3 = NULL;
return0;
}
/****输出****
who and who will get together !
who and who will get together !
************/