字符串指针法赋值

 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
",b);
10     printf("%s
",b);
11     for(int i=0;*(b+i)!=0;i++)
12         printf("%c",*(b+i));
13     printf("
");
14     return 0;
15 }

运行结果:

原文地址:https://www.cnblogs.com/bboykaku/p/12481922.html