注意!不要忘记加上字符串结束符'\0'
#include <iostream> using namespace std; # define N 1000 void MyStrcat(char dstStr[],char srcStr[]){ char *p = dstStr; char *q = srcStr; while (*p != '\0'){ p++; } while (*q != '\0'){ *p++ = *q++; } *p = '\0'; //不要忘记加上字符串结束符'\0' } int main() { char str1[N],str2[N]; while (cin >> str1 >> str2) { // 注意 while 处理多个 case MyStrcat(str1, str2); cout << str1 << endl; //cout << str2 << endl; } } // 64 位输出请用 printf("%lld")