X hits on this document

155 views

0 shares

0 downloads

0 comments

49 / 63

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

8-49

2D array in address space(2)

int a[2][3];  // 2 rows and 3 cols

Alternative interpretation: Three 1D array of 4 integers.

The base address of the array is &a[0][0].

The array name a by itself is equivalent to &a[0]. This time it is a pointer to an array of 3 elements.

Different ways to access (i,j) th element:

a[i][j]

*(a[i] + j)

*((*(a+i)) + j)

*(&a[0][0] + 4*i + j)

a[0][0]

a[0][1]

a[0][2]

a[1][0]

a[1][1]

a[1][2]

a

a+1

Document info
Document views155
Page views155
Page last viewedThu Dec 08 16:58:56 UTC 2016
Pages63
Paragraphs754
Words4119

Comments