With reference to the definition of two-dimensional array

Defined two-dimensional array

01: The most simple definition.

int a[3][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

02: The default number of rows Statement

int a[][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

03: consequently no shortage gave you draw a good braces

int a[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};

04: There are some little rascal, do not give you all the number are written

int a[3][4] = {{1}, {56}, {9}};

Remember, no written all treated as 0;

Call two-dimensional array

01: Direct call

int t;
t = a [2] [3]; // assign the third row to the fourth element t

 02: An example

/ * If the definition:
int w[3][5]; 
Then the following expression can not correctly represent the array elements are

A) *(&w[0][0]+1)

B) *(*w+3)

C) *(*(w+1))

D) *(w+1)[4]
*/

*(*(w+1))//<-->w[1][0]。

* (W + 1) [4] // <-> w [5] [0], so that the subject selected from the group D

Option // A * (& w [0] [0] +1) represents w [0] [1];

// B Options * (* w + 3) represents w [0] [3];

Option // C * (* (w + 1)) represented by w [0] [1];

------------------------------------------------------------------------

To be continued

------------------------------------------------------------------------

 

Guess you like

Origin www.cnblogs.com/franksimon/p/12609457.html