#include <iostream> #include <cstring> int main() { const char *cp1 = "Hello!"; const char *cp2 = "How are you."; size_t len = strlen(cp1) + strlen(cp2); char *result = new char[len]; strcpy(result, cp1); strcat(result, cp2); while(len--) { std::cout << *result; ++result; } delete [] result; return 0; }
时间: 2024-10-04 10:32:30