#include <stdio.h>
#include <stdlib.h>
/**int main()
{
char a[]="i love you very mach!",b[100];
int i;
for(i=0;*(a+i)!='\0';i++)
{
*(b+i)=*(a+i);
}
*(b+i)='\0';
printf("a:%s\n",a);
printf("b:");
for(i=0;*(b+i)!='\0';i++)
printf("%c",*(b+i));
printf("\n");
return 0;
}**/
/**下面用指针来处理这个问题**/
int main()
{
char a[]="i love you!",b[100];
char *p1,*p2;
p1=a;p2=b;
for(;*p1!='\0';p1++,p2++)
*p2=*p1;
*p2='\0';
printf("a:%s\n",a);
printf("b:%s\n",b);
return 0;
}
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)