About multidimensional array

C

CBFalconer

pete said:
"Sometimes I do that as a cheap and easy way of saving
the explanation in my email "Sent box"."

Then don't. Most readers have a means of copying a response
somewhere. For example, I have an area named 'Infosave', with some
subdirectories. If I need to keep a message I just copy it there.
Takes about 2 1/4 seconds.

You are using Mozilla, which is a descendent of the Netscape I am
using. Investigate the message menu, especially the copy submenu.

drazet is using Thunderbird, and the same suggestion applies.
 
C

CBFalconer

Richard said:
somenath said:
Then, given the definition that a "means" (*(a) + (b)), this


Will it not be *((a) + (b)) ?


Yes.

Congratulations! You caught out Chris Torek in a mistake. That is
such a rare achievement as to deserve a modding up.


Does Chris Torek hand out checks (or cheques) for $2.56?
 
R

Richard Heathfield

CBFalconer said:
Richard said:
somenath said:
Then, given the definition that a "means" (*(a) + (b)), this

Will it not be *((a) + (b)) ?


Yes.

Congratulations! You caught out Chris Torek in a mistake. That is
such a rare achievement as to deserve a modding up.


Does Chris Torek hand out checks (or cheques) for $2.56?


Not as far as I'm aware.

I would not have spotted somenath's correction, were it not for pete's
reply to him, which - unusually for pete - missed the point completely.
That's because somenath uses a gmail account, and by default I ignore
articles coming from such accounts. I have modded up several gmail
users known to be clueful, however, and he has now joined their ranks.
 
B

Barry Schwarz

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].
is *(pw+1)[2] wrong?why?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top