将两个字符串连接起来,不能用strcat函数。
将两个字符串连接起来,不能用strcat函数。
将两个字符串连接起来,不能用strcat函数。

将两个字符串连接起来,不能用strcat函数。
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 真相重于对错 2021-12-02 21:58关注
char* str1=new char[]{"123" }; char* str2 = new char[] {"234"}; int s1 = strlen(str1); int s2 = strlen(str2); str1 = (char*)realloc(str1, s1 + s2 + 1); char* p = str1 + s1; while (*str2 != '\0') { *p++ = *str2++; } *p = '\0';
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1