Hope the inline comments makes it clear.
#include <stdio.h>
int main()
{
char s1[]="abcd",s2[]="cdef",s3[5],*cp;
printf("s1 = %p
", (void*)s1); // prints start address of s1
cp = s1+2; // cp points to 2 chars advanced of s1 i.e 'c'
printf("cp = %p
", (void*)cp); // prints address at 'c'
//first increment cp to point to next location, which now points at 'd' from 'c'
//the outer ++ increments 'd' to 'e' post-fix, so first prints 'd'
printf("(*(++cp))++ = %c
", (*(++cp))++);
printf("s1 = %s
", s1); // you will see "abce"
printf("s1+2 = %s
", s1+2); // 2 chars advanced of s1, i.e "ce"
//printf("%c %s
",(*(++cp))++,s1+2);
return 0;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…