One dimensional array |
int foo [5]; // Array contains integers
Initialize:
foo [5] = {1, 2, 3, 4, 5};
foo [5] = {1, 2, 3,}; // 3rd and 4th element are assigned zero
foo [5] = {}; // All elements are assigned zero
foo [] = {1, 2, 3, 4, 5};
Function:
void procedure (int arg[]);
Pass by value:
Pass by reference:
procedure (foo);
Pass by pointer:
|
Two dimensional array |
int foo [2][3]; // [row x col] Array contains integers
// Total row*col elements
Initialize:
foo [2][3] = {{1, 2, 3}, {4, 5, 6}};
foo [2][3] = {1, 2, 3, 4, 5, 6};
foo [][] = {{1, 2, 3}, {4, 5, 6}};
foo [][] = {1, 2, 3, 4, 5, 6};
foo [2][3] = {{1, 2, 3}}; // All rest elements are assigned zero
foo [2][3] = {}; // All elements are assigned zero
|
No comments:
Post a Comment