12.23
char *concatenate_string = new char[strlen("hello " "world") + 1]();
strcat(concatenate_string, "hello ");
strcat(concatenate_string, "world");
std::cout << concatenate_string << std::endl;
delete [] concatenate_string;
// std::string
std::string str1{ "hello " }, str2{ "world" };
std::cout << str1 + str2 << std::endl;
12.24
std::cout << "How long do you want the string? ";
int size{ 0 };
std::cin >> size;
char *input = new char[size+1]();
std::cout << "input the string: ";
std::cin.get(input, size+1);
std::cout << input;
delete [] input;
超出的部分会被舍弃
12.25
delete [] pa;