我是 c 世界的新手,我想将两个数组合并为一个数组,我知道如何做到这一点,但它不起作用:P
char *s_one[] = { "Zorro", "Alex", "Celine" };
char *s_two[] = { "Zorro1", "Alex1"};
char *p = (char*)malloc((sizeof(s_one)+sizeof(s_two))*sizeof(char));
memcpy(p, s_one, sizeof(s_one));
memcpy(p + sizeof(s_one), s_two, sizeof(s_two));
//print out
for (count = 0; count < sizeof(p); count++)
printf("\narr[%d] = %c.", count, p[count]);
输出只是一些随机字符......我做错了什么,提前感谢每个提示
输出应该是: Zorro Alex Celine Zorro1 Alex1