方法一
include
void main()
{ char a[]="I am a boy.",b[20],p1,p2;
int i;
p1=a;
p2=b;
for(;p1!='\0';p1++,p2++) p2=p1; /当p1=='\0'时结束循环,因此'\0'并没有复制到p2上/ p2='\0';
printf("string a is:%s\n",a);
printf("string b is:%s\n",b);
printf("\n");
}
方法二
include
void main()
{ char a="I am a boy.",b;
b=a;
printf("string a is:%s\n",a);
printf("string b is:%s\n",b);
printf("\n");
}