1:代碼如下

// 6.15.cpp : 定義控制台應用程序的入口點。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { char str1[50], str2[30], *p1, *p2; p1 = str1; p2 = str2; cout << "please input string1:" << endl; gets_s(str1); cout << "please input string2:" << endl; gets_s(str2); strcat_s(str1, str2);//對字符串也行,對數組也行 cout << "the new string is:" << endl; puts(str1); }
運行結果: