void main() {char *p,b[10]="a,b,c,d,e,f,g,h,i"; int i; for(i=0,p=b;i<10;i++) *p++=*p+1; p=b+5; printf("%c",*p); }
*p++=p+1这句话,先执行p=*p+1,也就是字符增长了1,如'a'变成'b' for循环执行完毕后,b中的元素都增长了1。也就是变成了bcdefghij。p=b+5就相当于b[5],也就是g
#include <stdio.h>
void main()
{
char *p, b[10] = "abcdefghi";//应该去掉逗号
int i;
for (i = 0, p = b; i < 10; i++)
*p++ = *p + 1;
p = b + 5;
printf("%c", *p);
}
首先循环给指针p赋值,循环后p=b+5;由于b为b[0],b+5则为b[5]对应的值为g,所以输出的p指针指向的值为g