664Views3Replies

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.

Discussions

0
None
orksecurity

7 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
None
frollardorksecurity

Answer 7 years ago

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