char ch1[] = "abc"; char ch2[] = "def"; char ch3[20]; int i = 0; int k = 0; while (ch1[i] != ‘\0‘) { ch3[i] = ch1[i]; i++; } while (ch2[k] != ‘\0‘) { ch3[k + i] = ch2[k]; k++; } ch3[k + i] = ‘\0‘; printf("%s\n", ch3); 注意: 字符串和字符数组到区别 字符串结尾带有‘\0‘ 字符数组没有‘\0‘
原文:https://www.cnblogs.com/mayichen0823/p/10163885.html