X hits on this document

149 views

0 shares

0 downloads

0 comments

48 / 63

Copyright ©2004 Pearson Addison-Wesley. All rights reserved.

8-48

2D array in address space(1)

How to store a multi-dimensional array into a one-dimensional memory space.

Row major ordering assigns successive elements, moving across the rows and then down the columns, to successive memory locations.

Address of a[row][col]  = Base_Address + (row * row_size + col) Base_Address is the address of the first element of the array (A[0][0] in this case).

char *base = &A[0][0];

Referring A[i][j] is same as referring *(base+4*i+j);

Document info
Document views149
Page views149
Page last viewedWed Dec 07 16:38:24 UTC 2016
Pages63
Paragraphs754
Words4119

Comments