标签:
main()
{
char *p1 = "name";
char *p2;
p2 = (char *)malloc(20);
memset(p2,0,20);
while(*p2++ = *p1++);
printf("p2 = %s \n",p2);
}
输出结果为空的原因是:p2指针移动了5个,指向了NULL。
while(*p2++ = *p1++);的详细展开如下:
do {
t1 = p1;
p1++;
t2 = p2;
p2++;
*t2 = *t1;
}while(*t2);
标签:
原文地址:http://www.cnblogs.com/beella/p/5399512.html