The structure operators . and ->, together with () for function calls and [] for subscripts, are at the top of the precedence hierarchy and thus bind very tightly. For example, given the declaration
struct {
int len;
char *str;
} *p;
then
++p->len
increments len, not p, because the implied parenthesization is ++(p->len).
In the same way, *p->str fetches whatever str points to; *p->str++ increments str after accessing whatever it points to (just like *s++); (*p->str)++ increments whatever str points to; and *p++->str increments p after accessing whatever str points to.
struct {
int len;
char *str;
} *p;
then
++p->len
increments len, not p, because the implied parenthesization is ++(p->len).
In the same way, *p->str fetches whatever str points to; *p->str++ increments str after accessing whatever it points to (just like *s++); (*p->str)++ increments whatever str points to; and *p++->str increments p after accessing whatever str points to.
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}