hi,all
i have a question about multidimensional array.
int w[2][3],(*pw)[3];
pw=w;
With a few exceptions that don't apply to your examples, an expression
of type array is converted to the address of the first element of the
array with type pointer to element type. So this statement is exactly
the same as pw = &w[0].
Since [] has higher precedence than *, this is parsed as
*((pw+1)[2])
(pw+1) evaluates to the address of w[1].
(pw+1)[0] evaluates to the array (pw+1) points to, namely w[1].
(pw+1)[1] would evaluate to the next array beyond w[1] and (pw+1)[2]
would evaluate to the second array beyond w[1]. Unfortunately,
neither of these two arrays exist since w[0] and w[1] are the only two
defined.
If w[3] existed, then *(pw+1)[2] would evaluate to w[3][0].
If your intent was to get the last scalar element of w, then use
either (*(pw+1))[2] or the equivalent and preferable pw[1][2].
and *(w[0]+2),pw[0][0] and *(pw[1]+2) mean?
By definition, *(w[0]+2) is exactly the same as w[0][2].
Since pw points to w, pw[0][0] is the same as w[0][0].
Applying the previous two rules, you should have no trouble
deciphering *(pw[1]+2).
Remove del for email