字符串指针法赋值
1 //字符串指针法赋值 2 # include<stdio.h> 3 char a[]="I am a student!"; 4 char b[20]; 5 char *p1=a,*p2=b; 6 int main() 7 { 8 while(*p2++=*p1++); //while(*b++=*a++)或while((*b++=*a++)!=0) 9 printf("%s\n",b); 10 printf("%s\n",b); 11 for(int i=0;*(b+i)!=0;i++) 12 printf("%c",*(b+i)); 13 printf("\n"); 14 return 0; 15 }
运行结果: