将两个字符串合并追加在一起, 类似于python的str1+str2
#include<stdio.h> #include<string.h> #include<stdlib.h> //字符串追加, 将两个字符串结合在一起 int main() { char str1[128] = "shunguo"; char str2[128] = "age"; // 输出的结果要变成shunguoage int i = 0; int j = strlen(str1); while (str2[i] != '\0') { str1[j] = str2[i]; j++; i++; } printf("str1 is %s",str1); return 0; }
shunguoage
标签:--,str2,str1,C语言,int,字符串,include From: https://www.cnblogs.com/shunguo/p/16886727.html