Basics of Structure Triple Dimension Array ============================================= In this section, you are going to learn .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What are the basic properties of a structure triple dimension array ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What are the different expressions of triple dimension array ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What are synonymous expresions of triple dimension array ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How to find sizeof() of expressions of triple dimension array ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Structure Triple Dimension Array : Syntax ` * :ref:`Structure Triple Dimension Array : FAQs ` * :ref:`Structure Triple Dimension Array : Basic Examples ` * :ref:`Structure Triple Dimension Array : Basic Example 1 ` * :ref:`Structure Triple Dimension Array : Basic Properties ` * :ref:`Structure Triple Dimension Array : Basic Expressions ` * :ref:`Structure Triple Dimension Array : Synonym Expressions ` * :ref:`Structure Triple Dimension Array : typeof(expression) ` * :ref:`Structure Triple Dimension Array : sizeof(expression) ` * :ref:`Structure Triple Dimension Array : fun(expression) ` * :ref:`Structure Triple Dimension Array : All Examples of Function Calls ` .. _array_n_ptrs_struct_td_array_ex_0: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : Syntax .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow struct XYZ array_name[Block][Row][Column]; .. _array_n_ptrs_struct_td_array_ex_0_1: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : FAQs Consider a structure triple dimension array .. code-block:: c struct XYZ a[3][4][5]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us answer few basic questions in this array .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How many structures can be stored in this array ? .. dropdown:: See Answer Number of Structures = 3 * 4 * 5 = 60 .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How many bytes are there in this array ? .. dropdown:: See Answer Number of Bytes = 3 * 4 * 5 * sizeof(struct XYZ) = 60 * 12 = 720 Bytes .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What is the sizeof the array ? .. dropdown:: See Answer sizeof(a) = Number of Bytes = 3 * 4 * 5 * sizeof(struct XYZ) = 60 * 12 = 720 Bytes .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How many single dimension arrays are present in this triple dimension array ? .. dropdown:: See Answer There are, 3 * 4 = 12 Single dimension arrays. Size of each single dimension array is 60 Bytes .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How many double dimension arrays are present in this triple dimension array ? .. dropdown:: See Answer There are 3 Double dimension arrays. Size of each double dimension array is 4 * 5 * sizeof(struct XYZ) = 240 Bytes .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What are the names of double dimension arrays in this triple dimension array ? .. dropdown:: See Answer a[0] a[1] a[2] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What are the names of single dimension arrays in this triple dimension array ? .. dropdown:: See Answer a[0][0] a[0][1] a[0][2] a[0][3] a[1][0] a[1][1] a[1][2] a[1][3] a[2][0] a[2][1] a[2][2] a[2][3] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How do you represent the first structure ? .. dropdown:: See Answer a[0][0][0] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How do you represent the last structure ? .. dropdown:: See Answer a[2][3][4] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How do you initialise the array at the time of declaration ? .. dropdown:: See Answer .. code-block:: c struct XYZ { int x; int y; int z; }; struct XYZ a[2][3][4] = { {//a[0] { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, }, {//a[1] { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, }, }; .. _array_n_ptrs_struct_td_array_ex_0_1_0: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : Basic Examples .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us now explore basic examples of triple dimension array ! .. _array_n_ptrs_struct_td_array_ex_0_2: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : Basic Example 1 * Step 1 : Define a Triple Dimension Array .. code-block:: c struct XYZ a[2][3][4] = { {//a[0] { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, }, {//a[1] { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, }, }; * Step 2 : Access and Print individual structures .. code-block:: c for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 4; k++) { printf("a[%d][%d][%d].x = %d ", i, j, k, a[i][j][k].x); printf("a[%d][%d][%d].y = %d ", i, j, k, a[i][j][k].y); printf("a[%d][%d][%d].z = %d ", i, j, k, a[i][j][k].z); printf("\n"); } printf("\n"); } printf("\n"); } * See the full program below .. code-block:: c #include struct XYZ { int x; int y; int z; }; int main(void) { struct XYZ a[2][3][4] = { {//a[0] { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, }, {//a[1] { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, { {1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, }, }, }; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 4; k++) { printf("a[%d][%d][%d].x = %d ", i, j, k, a[i][j][k].x); printf("a[%d][%d][%d].y = %d ", i, j, k, a[i][j][k].y); printf("a[%d][%d][%d].z = %d ", i, j, k, a[i][j][k].z); printf("\n"); } printf("\n"); } printf("\n"); } return 0; } * Output is as below .. code-block:: c a[0][0][0].x = 1 a[0][0][0].y = 1 a[0][0][0].z = 1 a[0][0][1].x = 2 a[0][0][1].y = 2 a[0][0][1].z = 2 a[0][0][2].x = 3 a[0][0][2].y = 3 a[0][0][2].z = 3 a[0][0][3].x = 4 a[0][0][3].y = 4 a[0][0][3].z = 4 a[0][1][0].x = 1 a[0][1][0].y = 1 a[0][1][0].z = 1 a[0][1][1].x = 2 a[0][1][1].y = 2 a[0][1][1].z = 2 a[0][1][2].x = 3 a[0][1][2].y = 3 a[0][1][2].z = 3 a[0][1][3].x = 4 a[0][1][3].y = 4 a[0][1][3].z = 4 a[0][2][0].x = 1 a[0][2][0].y = 1 a[0][2][0].z = 1 a[0][2][1].x = 2 a[0][2][1].y = 2 a[0][2][1].z = 2 a[0][2][2].x = 3 a[0][2][2].y = 3 a[0][2][2].z = 3 a[0][2][3].x = 4 a[0][2][3].y = 4 a[0][2][3].z = 4 a[1][0][0].x = 1 a[1][0][0].y = 1 a[1][0][0].z = 1 a[1][0][1].x = 2 a[1][0][1].y = 2 a[1][0][1].z = 2 a[1][0][2].x = 3 a[1][0][2].y = 3 a[1][0][2].z = 3 a[1][0][3].x = 4 a[1][0][3].y = 4 a[1][0][3].z = 4 a[1][1][0].x = 1 a[1][1][0].y = 1 a[1][1][0].z = 1 a[1][1][1].x = 2 a[1][1][1].y = 2 a[1][1][1].z = 2 a[1][1][2].x = 3 a[1][1][2].y = 3 a[1][1][2].z = 3 a[1][1][3].x = 4 a[1][1][3].y = 4 a[1][1][3].z = 4 a[1][2][0].x = 1 a[1][2][0].y = 1 a[1][2][0].z = 1 a[1][2][1].x = 2 a[1][2][1].y = 2 a[1][2][1].z = 2 a[1][2][2].x = 3 a[1][2][2].y = 3 a[1][2][2].z = 3 a[1][2][3].x = 4 a[1][2][3].y = 4 a[1][2][3].z = 4 .. _array_n_ptrs_struct_td_array_ex_1: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : Basic Properties .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us now explore Triple Dimension Array in depth ! .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Consider a Triple dimension array .. code-block:: c struct XYZ a[3][4][5]; Below are the properties * Expressions * Synonyms * typeof(expression) * sizeof(expression) * fun(expression) .. _array_n_ptrs_struct_td_array_ex_2: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : Basic Expressions .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Know what are the possible expressions and how to properly call them ! ============================================= ==================================================================================== Expression Description ============================================= ==================================================================================== a[0][0][0] * ``a[0][0][0]`` is a Structure a[1][0][0] * ``a[1][0][0]`` is a Structure a[2][0][0] * ``a[2][0][0]`` is a Structure &a[0][0][0] * ``&a[0][0][0]`` is address of a Structure &a[1][0][0] * ``&a[1][0][0]`` is address of a Structure &a[2][0][0] * ``&a[2][0][0]`` is address of a Structure \*\*\*a * ``***a`` is Structure. Same as a[0][0][0] \*(\*(\*(a + 1) + 0) + 0) * ``*(*(*(a + 1) + 0) + 0)`` is a Structure. Same as a[1][0][0] \*(\*(\*(a + 2) + 0) + 0) * ``*(*(*(a + 2) + 0) + 0)`` is a Structure. Same as a[2][0][0] a[0][0] * ``a[0][0]`` is a Single Dimension Array a[1][0] * ``a[1][0]`` is a Single Dimension Array a[2][0] * ``a[1][1]`` is a Single Dimension Array &a[0][0] * ``&a[0][0]`` is address of a Single Dimension Array &a[1][0] * ``&a[1][0]`` is address of a Single Dimension Array &a[2][0] * ``&a[2][0]`` is address of a Single Dimension Array \*\*a * ``**a`` is a Single Dimension Array. Same as a[0][0] \*(\*(a + 1) + 0) * ``*(*(a + 1) + 0)`` is a Single Dimension Array. Same as a[1][0] \*(\*(a + 2) + 0) * ``*(*(a + 2) + 0)`` is a Single Dimension Array. Same as a[2][0] a[0] * ``a[0]`` is a Double Dimension array a[1] * ``a[1]`` is a Double Dimension array a[2] * ``a[2]`` is a Double Dimension array &a[0] * ``&a[0]`` is address of a Double Dimension array &a[1] * ``&a[1]`` is address of a Double Dimension array &a[2] * ``&a[2]`` is address of a Double Dimension array \*a * ``*a`` is a Double Dimension array \*(a + 1) * ``*(a + 1)`` is a Double Dimension array \*(a + 2) * ``*(a + 2)`` is a Double Dimension array a * ``a`` is address of a Double Dimension array. Same as &a[0] a + 1 * ``a + 1`` is address of a Double Dimension array. Same as &a[1] a + 2 * ``a + 2`` is address of a Double Dimension array. Same as &a[2] &a * ``&a`` is the address of Triple Dimension array ============================================= ==================================================================================== .. _array_n_ptrs_struct_td_array_ex_3: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : Synonym Expressions .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Synonyms : Which can be used interchangeably ! .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Programmatically few expressions are one and the same ! Let us learn them ============================================ ======================================== Expression Synonyms ============================================ ======================================== a[0][0][0] ``***a`` a[1][0][0] ``*(*(*(a + 1) + 0) + 0)`` a[2][0][0] ``*(*(*(a + 2) + 0) + 0)`` &a[0][0][0] ``a[0][0]`` &a[1][0][0] ``a[1][0]`` &a[2][0][0] ``a[2][0]`` \*\*\*a ``a[0][0][0]`` \*(\*(\*(a + 1) + 0) + 0) ``a[1][0][0]`` \*(\*(\*(a + 2) + 0) + 0) ``a[2][0][0]`` a[0][0] ``**a`` a[1][0] ``*(*(a + 1) + 0)`` a[2][0] ``*(*(a + 2) + 0)`` &a[0][0] ``a[0]`` &a[1][0] ``a[1]`` &a[2][0] ``a[2]`` \*\*a ``a[0][0]`` \*(\*(a + 1) + 0) ``a[1][0]`` \*(\*(a + 2) + 0) ``a[2][0]`` a[0] ``*a`` ``&a[0][0]`` a[1] ``*(a + 1)`` ``&a[1][0]`` a[2] ``*(a + 2)`` ``&a[2][0]`` &a[0] ``a + 0`` ``a`` &a[1] ``a + 1`` &a[2] ``a + 2`` \*a ``a[0]`` ``&a[0][0]`` \*(a + 1) ``a[1]`` ``&a[1][0]`` \*(a + 2) ``a[2]`` ``&a[2][0]`` a ``&a[0]`` a + 1 ``&a[1]`` a + 2 ``&a[2]`` &a ``&a`` ============================================ ======================================== .. _array_n_ptrs_struct_td_array_ex_4: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : typeof(expression) .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Finding the type of an expression is easy. See below ============================== ======================== ========================================================= Expression Type Description ============================== ======================== ========================================================= a[0][0][0] struct XYZ * is a Structure a[1][0][0] struct XYZ * is a Structure a[2][0][0] struct XYZ * is a Structure &a[0][0][0] struct XYZ * is a Structure &a[1][0][0] struct XYZ * is a Structure &a[2][0][0] struct XYZ * is a Structure \*\*\*a struct XYZ * is a Structure \*(\*(\*(a + 1) + 0) + 0) struct XYZ * is a Structure \*(\*(\*(a + 2) + 0) + 0) struct XYZ * is a Structure a[0][0] struct XYZ * * ``a[0][0]`` is a Single Dimension Array a[1][0] struct XYZ * * ``a[1][0]`` is a Single Dimension Array a[2][0] struct XYZ * * ``a[2][0]`` is a Single Dimension Array &a[0][0] struct XYZ (*)[5] * ``&a[0][0]`` is address of a Single Dimension Array &a[1][0] struct XYZ (*)[5] * ``&a[1][0]`` is address of a Single Dimension Array &a[2][0] struct XYZ (*)[5] * ``&a[2][0]`` is address of a Single Dimension Array \*\*a struct XYZ * * ``**a`` is a Single Dimension Array. Same as a[0][0] \*(\*(a + 1) + 0) struct XYZ * * ``*(*(a + 1) + 0)`` is a Single Dimension Array. Same as ``a[1][0]`` \*(\*(a + 2) + 0) struct XYZ * * ``*(*(a + 2) + 0)`` is a Single Dimension Array. Same as ``a[2][0]`` a[0] struct XYZ (*)[5] * ``a[0]`` is a Double Dimension structure array * ``a[0]`` is array of Single Dimension Arrays * Since every unit is a Single Dimension Array, a pointer to a single dimension array is needed a[1] struct XYZ (*)[5] * ``a[1]`` is a Double Dimension structure array * ``a[1]`` is array of Single Dimension Arrays * Since every unit is a Single Dimension Array, a pointer to a single dimension array is needed a[2] struct XYZ (*)[5] * ``a[2]`` is a Double Dimension structure array * ``a[2]`` is array of Single Dimension Arrays * Since every unit is a Single Dimension Array, a pointer to a single dimension array is needed &a[0] struct XYZ (*)[4][5] * ``a[0]`` is a Double Dimension structure array * Hence ``typeof(&a[0])`` is ``struct XYZ (*)[4][5]`` &a[1] struct XYZ (*)[4][5] * ``a[1]`` is a Double Dimension structure array * Hence ``typeof(&a[1])`` is ``struct XYZ (*)[4][5]`` &a[2] struct XYZ (*)[4][5] * ``a[2]`` is a Double Dimension structure array * Hence ``typeof(&a[2])`` is ``struct XYZ (*)[4][5]`` \*a struct XYZ (*)[5] * ``*a`` is a Double Dimension structure array * ``*a`` is array of Single Dimension Arrays * Since every unit is a Single Dimension Array, a pointer to a single dimension array is needed \*(a + 1) struct XYZ (*)[5] * ``*(a + 1)`` is a Double Dimension structure array * ``*(a + 1)`` is array of Single Dimension Arrays * Since every unit is a Single Dimension Array, a pointer to a single dimension array is needed \*(a + 2) struct XYZ (*)[5] * ``*(a + 2)`` is a Double Dimension structure array * ``*(a + 2)`` is array of Single Dimension Arrays * Since every unit is a Single Dimension Array, a pointer to a single dimension array is needed a struct XYZ (*)[4][5] * ``a`` is equal to ``&a[0]`` * Hence ``typeof(a)`` is ``struct XYZ (*)[4][5]`` a + 1 struct XYZ (*)[4][5] * ``a + 1`` is equal to ``&a[1]`` * Hence ``typeof(a + 1)`` is ``struct XYZ (*)[4][5]`` a + 2 struct XYZ (*)[4][5] * ``a + 2`` is equal to ``&a[2]`` * Hence ``typeof(a + 2)`` is ``struct XYZ (* )[4][5]`` &a struct XYZ (*)[3][4][5] * ``&a`` is address of complete array ============================== ======================== ========================================================= .. _array_n_ptrs_struct_td_array_ex_5: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : sizeof(expression) ====================================== ========= =============================== sizeof(expression) size Description ====================================== ========= =============================== sizeof(a[0][0][0]) 12 a[0][0][0] is a structure sizeof(a[1][0][0]) 12 a[1][0][0] is a structure sizeof(a[2][0][0]) 12 a[2][0][0] is a structure sizeof(&a[0][0][0]) 8 &a[0][0][0] is address / pointer sizeof(&a[1][0][0]) 8 &a[1][0][0] is address / pointer sizeof(&a[2][0][0]) 8 &a[2][0][0] is address / pointer sizeof(\*\*\*a) 12 \*\*\*a is a structure sizeof(\*(\*(\*(a + 1) + 0) + 0)) 12 \*(\*(\*(a + 1) + 0) + 0) is a structure sizeof(\*(\*(\*(a + 2) + 0) + 0)) 12 \*(\*(\*(a + 2) + 0) + 0) is a structure sizeof(a[0][0]) 60 a[0][0] is a Single Dimension Array sizeof(a[1][0]) 60 a[1][0] is a Single Dimension Array sizeof(a[2][0]) 60 a[2][0] is a Single Dimension Array sizeof(&a[0][0]) 8 &a[0][0] is address / pointer sizeof(&a[1][0]) 8 &a[1][0] is address / pointer sizeof(&a[2][0]) 8 &a[2][0] is address / pointer sizeof(\*\*a) 60 \*\*a is a Single Dimension Array sizeof(\*(\*(a + 1) + 0)) 60 \*(\*(a + 1) + 0) is a Single Dimension Array sizeof(\*(\*(a + 2) + 0)) 60 \*(\*(a + 2) + 0) is a Single Dimension Array sizeof(a[0]) 240 a[0] is a Double Dimension Array sizeof(a[1]) 240 a[1] is a Double Dimension Array sizeof(a[2]) 240 a[2] is a Double Dimension Array sizeof(&a[0]) 8 &a[0] is address / pointer sizeof(&a[1]) 8 &a[1] is address / pointer sizeof(&a[2]) 8 &a[2] is address / pointer sizeof(\*a) 240 \*a is a Double Dimension Array sizeof(\*(a + 1)) 240 \*(a + 1) is a Double Dimension Array sizeof(\*(a + 2)) 240 \*(a + 2) is a Double Dimension Array sizeof(a) 720 a is a triple dimension array sizeof(a + 1) 8 a + 1 is address / pointer sizeof(a + 2) 8 a + 2 is address / pointer sizeof(&a) 8 &a is address / pointer ====================================== ========= =============================== * See the full program below .. code-block:: c #include int main(void) { struct XYZ a[3][4][5]; printf("sizeof(a[0][0][0]) = %d\n", (int) sizeof(a[0][0][0]) ); printf("sizeof(a[1][0][0]) = %d\n", (int) sizeof(a[1][0][0]) ); printf("sizeof(a[2][0][0]) = %d\n", (int) sizeof(a[2][0][0]) ); printf("sizeof(&a[0][0][0]) = %d\n", (int) sizeof(&a[0][0][0]) ); printf("sizeof(&a[1][0][0]) = %d\n", (int) sizeof(&a[1][0][0]) ); printf("sizeof(&a[2][0][0]) = %d\n", (int) sizeof(&a[2][0][0]) ); printf("sizeof(***a) = %d\n", (int) sizeof(***a) ); printf("sizeof(*(*(*(a + 1) + 0) + 0)) = %d\n", (int) sizeof(*(*(*(a + 1) + 0) + 0)) ); printf("sizeof(*(*(*(a + 2) + 0) + 0)) = %d\n", (int) sizeof(*(*(*(a + 2) + 0) + 0)) ); printf("sizeof(a[0][0]) = %d\n", (int) sizeof(a[0][0]) ); printf("sizeof(a[1][0]) = %d\n", (int) sizeof(a[1][0]) ); printf("sizeof(a[2][0]) = %d\n", (int) sizeof(a[2][0]) ); printf("sizeof(&a[0][0]) = %d\n", (int) sizeof(&a[0][0]) ); printf("sizeof(&a[1][0] = %d\n", (int) sizeof(&a[1][1]) ); printf("sizeof(&a[2][0]) = %d\n", (int) sizeof(&a[2][0]) ); printf("sizeof(**a) = %d\n", (int) sizeof(**a)); printf("sizeof(*(*(a + 1) + 0)) = %d\n", (int) sizeof(*(*(a + 1) + 0)) ); printf("sizeof(*(*(a + 2) + 0)) = %d\n", (int) sizeof(*(*(a + 2) + 0)) ); printf("sizeof(a[0]) = %d\n", (int) sizeof(a[0]) ); printf("sizeof(a[1]) = %d\n", (int) sizeof(a[1]) ); printf("sizeof(a[2]) = %d\n", (int) sizeof(a[2]) ); printf("sizeof(&a[0]) = %d\n", (int) sizeof(&a[0]) ); printf("sizeof(&a[1]) = %d\n", (int) sizeof(&a[1]) ); printf("sizeof(&a[2]) = %d\n", (int) sizeof(&a[2]) ); printf("sizeof(*a) = %d\n", (int) sizeof(*a) ); printf("sizeof(*(a + 1)) = %d\n", (int) sizeof(*(a + 1)) ); printf("sizeof(*(a + 2)) = %d\n", (int) sizeof(*(a + 2)) ); printf("sizeof(a) = %d\n", (int) sizeof(a) ); printf("sizeof(a + 1) = %d\n", (int) sizeof(a + 1) ); printf("sizeof(a + 2) = %d\n", (int) sizeof(a + 2) ); printf("sizeof(&a) = %d\n", (int) sizeof(&a) ); return 0; } * Output is as below on 64 bit OS .. code-block:: c sizeof(a[0][0][0]) = 12 sizeof(a[1][0][0]) = 12 sizeof(a[2][0][0]) = 12 sizeof(&a[0][0][0]) = 8 sizeof(&a[1][0][0]) = 8 sizeof(&a[2][0][0]) = 8 sizeof(***a) = 12 sizeof(*(*(*(a + 1) + 0) + 0)) = 12 sizeof(*(*(*(a + 2) + 0) + 0)) = 12 sizeof(a[0][0]) = 60 sizeof(a[1][0]) = 60 sizeof(a[2][0]) = 60 sizeof(&a[0][0]) = 8 sizeof(&a[1][0] = 8 sizeof(&a[2][0]) = 8 sizeof(**a) = 60 sizeof(*(*(a + 1) + 0)) = 60 sizeof(*(*(a + 2) + 0)) = 60 sizeof(a[0]) = 240 sizeof(a[1]) = 240 sizeof(a[2]) = 240 sizeof(&a[0]) = 8 sizeof(&a[1]) = 8 sizeof(&a[2]) = 8 sizeof(*a) = 240 sizeof(*(a + 1)) = 240 sizeof(*(a + 2)) = 240 sizeof(a) = 720 sizeof(a + 1) = 8 sizeof(a + 2) = 8 sizeof(&a) = 8 .. _array_n_ptrs_struct_td_array_ex_6: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : fun(expression) .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If ``fun(x)`` is the function call, then ``fun(typeof(x))`` is the prototype / definition ========================== ====================================== ========================================================================== Function Call Function Definition Observations ========================== ====================================== ========================================================================== fun(a[0][0][0]) void fun(struct XYZ x) {} * Call by Value fun(a[1][0][0]) void fun(struct XYZ x) {} * Call by Value fun(a[2][0][0]) void fun(struct XYZ x) {} * Call by Value fun(&a[0][0][0]) void fun(struct XYZ \*p) {} * Call by Reference fun(&a[1][0][0]) void fun(struct XYZ \*p) {} * Call by Reference fun(&a[2][0][0]) void fun(struct XYZ \*p) {} * Call by Reference fun(a[0][0]) void fun(struct XYZ \*p) {} * Call by Reference fun(a[1][0]) void fun(struct XYZ \*p) {} * Call by Reference fun(a[2][0]) void fun(struct XYZ \*p) {} * Call by Reference fun(&a[0][0]) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(&a[1][0]) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(&a[2][0]) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(\*\*a) void fun(struct XYZ \*p) {} * Call by Reference fun(\*(\*(a + 1) + 0)) void fun(struct XYZ \*p) {} * Call by Reference fun(\*(\*(a + 2) + 0)) void fun(struct XYZ \*p) {} * Call by Reference fun(a[0]) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(a[1]) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(a[2]) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(&a[0]) void fun(struct XYZ (\*p)[4][5]) {} * Call by Reference fun(&a[1]) void fun(struct XYZ (\*p)[4][5]) {} * Call by Reference fun(&a[2]) void fun(struct XYZ (\*p)[4][5]) {} * Call by Reference fun(\*a) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(\*(a + 1)) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(\*(a + 2)) void fun(struct XYZ (\*p)[5]) {} * Call by Reference fun(a) void fun(struct XYZ (\*p)[4][5]) {} * Call by Reference fun(a + 1) void fun(struct XYZ (\*p)[4][5]) {} * Call by Reference fun(a + 2) void fun(struct XYZ (\*p)[4][5]) {} * Call by Reference fun(&a) void fun(struct XYZ (\*p)[3][4][5]) {} * Call by Reference ========================== ====================================== ========================================================================== .. _array_n_ptrs_struct_td_array_ex_7: .. tab-set:: .. tab-item:: Structure Triple Dimension Array : All Examples of Function Calls .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Read more about function calls and conventions of :doc:`../../funcs_n_ptrs/funcs_n_structs/struct_td_array` .. card:: See Also * Other topics of character and functions * :doc:`./struct_sd_array` * :doc:`./struct_dd_array` * :doc:`./struct_td_array` * Current Module * :doc:`../array_n_ptrs` * Previous Module * :doc:`../../basic_ptr/basic_ptr` * Next Module * :doc:`../../malloc_ptr/malloc_ptr` * Other Modules * :doc:`../../variable_and_ptr/variable_and_ptr` * :doc:`../../array_n_ptrs/array_n_ptrs` * :doc:`../../malloc_ptr/malloc_ptr` * :doc:`../../typecasting_n_ptr/typecasting_n_ptr` * :doc:`../../const_ptr/const_ptr` * :doc:`../../void_ptr/void_ptr` * :doc:`../../array_of_ptr/array_of_ptr` * :doc:`../../ptr_to_array/ptr_to_array` * :doc:`../../function_ptr/function_ptr` * :doc:`../../memcpy_ptr/memcpy_ptr` * :doc:`../../pre_incr_ptr/pre_incr_ptr` * :doc:`../../post_incr_ptr/post_incr_ptr` * :doc:`../../pre_decr_ptr/pre_decr_ptr` * :doc:`../../post_decr_ptr/post_decr_ptr`