732Views3Replies

Author Options:

arrays base address is 1000?.array is a[5][4]..then wat is the correct address of a[4][3]? ? Answered

It's a question on C programming.  Please explain the answer.

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
orksecurity
orksecurity

9 years ago

Homework assignment, I take it.

Can't be answered without knowing what it's an array of, and what size that datum is in memory on your machine's architecture, and what your machine's alignment rules are.

Once you know those, you should be able to figure out how the data are arranged in memory for one array, and (big hint) how one-dimensional and two-dimensional arrays are related. It may help to remember that array math and pointer math are fairly interchangable -- if a is an array, *(a+1) accesses the same location as a[1].

If that doesn't help you solve the problem, go back and reread your course notes. This is stuff you really do need to understand well if you're going to work in C, and handing you the answer won't help you learn it.

0
frollard
frollard

Answer 9 years ago

worst case scenario -- build the array, fill it with unique values, then actually read the memory dump.

0
iceng
iceng

Answer 9 years ago

+1