把两个字符串同时放进空数组里
#include <stdio.h>int main(){
char *s1="hello";
char *s2="world";
char s3[20];
int i,j=0;
for(i=0;i<20;i++){
s3[i]=*(s1+i);
if(s3[i]=='\0')
s3[i+1]=*(s2+j++);}
printf("%s\n",s3);
return 0;
}
#include <stdio.h> int main() { char *s1 = "hello"; char *s2 = "world"; char s3[20]; int i = 0; while (i < 20 && s1[i] != '\0') { s3[i] = s1[i]; ++i; } int j = 0; while (i < 20 && s2[j] != '\0') { s3[i++] = s2[j++]; } s3[i] = '\0'; printf("%s\n", s3); return 0; }