One dimensional array | int foo [5]; // Array contains integersInitialize: 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 elementsInitialize: 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 |
Wednesday, September 10, 2014
C/C++ Array
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment