Functions and 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 calling conventions of structure triple dimension array ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Call by Value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Call by Reference .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Revisit Basics : :doc:`../../array_n_ptrs/arrays_n_structs/struct_td_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 : fun(expression) ` * :ref:`Rules for Call By Value ` * :ref:`Example : Call by Value : Pass Structure : x[1][1][1] ` * :ref:`Example : Call by Value : Pass Structure : ***x ` * :ref:`Rules for Call By Reference ` * :ref:`Example : Call by Reference : &x[1][1] ` * :ref:`Example : Call by Reference : x[1] ` * :ref:`Examples of Call by Value ` * :ref:`Example 1 : Call by Value : Pass Structure : x[0][0][0], x[1][0][0] ` * :ref:`Example 2 : Call by Value : Pass Structure : \*\*\*x, \*(\*(\*(x + 1) + 0) + 0) ` * :ref:`Examples of Call by Reference ` * :ref:`Example 3 : Call by Reference : Pass Single dimension arrays which are part of a triple dimension array to a function ` * :ref:`Example 4 : Call by Reference : Pass Address of Single dimension arrays which are part of a triple dimension array to a function ` * :ref:`Example 5 : Call by Reference : Pass Double dimension arrays which are part of a Triple dimension array to a function ` * :ref:`Example 6 : Call by Reference : Pass Address of Double dimension arrays which are part of a Triple dimension array to a function ` * :ref:`Example 7 : Call by Reference : Pass Address of Triple Dimension array to a function ` .. _funcs_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 .. code-block:: c struct ABC { type1 member1; type2 member2; type3 member3; etc., }; struct ABC array_name[Block][Row][Column]; .. _funcs_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 ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us answer few basic questions in this array .. _funcs_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(x[0][0][0]) void fun(struct ABC x) {} * Call by Value fun(x[1][0][0]) void fun(struct ABC x) {} * Call by Value fun(&x[0][0][0]) void fun(struct ABC \*p) {} * Call by Reference fun(&x[1][0][0]) void fun(struct ABC \*p) {} * Call by Reference fun(x[0][0]) void fun(struct ABC \*p) {} * Call by Reference fun(x[1][0]) void fun(struct ABC \*p) {} * Call by Reference fun(&x[0][0]) void fun(struct ABC (\*p)[4]) {} * Call by Reference fun(&x[1][0]) void fun(struct ABC (\*p)[4]) {} * Call by Reference fun(\*\*x) void fun(struct ABC \*p) {} * Call by Reference fun(\*(\*(x + 1) + 0)) void fun(struct ABC \*p) {} * Call by Reference fun(x[0]) void fun(struct ABC (\*p)[4]) {} * Call by Reference fun(x[1]) void fun(struct ABC (\*p)[4]) {} * Call by Reference fun(&x[0]) void fun(struct ABC (\*p)[3][4]) {} * Call by Reference fun(&x[1]) void fun(struct ABC (\*p)[3][4]) {} * Call by Reference fun(\*x) void fun(struct ABC (\*p)[4]) {} * Call by Reference fun(\*(x + 1)) void fun(struct ABC (\*p)[4]) {} * Call by Reference fun(x) void fun(struct ABC (\*p)[3][4]) {} * Call by Reference fun(x + 1) void fun(struct ABC (\*p)[3][4]) {} * Call by Reference fun(&x) void fun(struct ABC (\*p)[2][3][4]) {} * Call by Reference ========================== ======================================== ========================================================================== .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us understand the reason behind above prototypes ! .. _funcs_n_ptrs_struct_td_array_ex_8: .. tab-set:: .. tab-item:: Rules for Call By Value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has THREE dereference operators \* \* \*, and * Expression does not have ``&`` * then it is call by value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has THREE dereference operators \* \* [ ], and * Expression does not have ``&`` * then it is call by value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has THREE dereference operators \* [ ] [ ], and * Expression does not have ``&`` * then it is call by value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has THREE dereference operators [] [] [], and * Expression does not have ``&`` * then it is call by value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us look at examples .. _funcs_n_ptrs_struct_td_array_ex_9: .. tab-set:: .. tab-item:: Example 1 : Call by Value : Pass Structure : x[1][1][1] * Step 1 : Consider an array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 1 : Declaration has THREE dereference operators [ ], [ ] and [ ] * Step 2 : Consider an expression ``x[1][1][1]`` .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 2 : Expression has THREE dereference operators [ ], [ ] and [ ] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Note : ``[ ]`` and ``*`` are dereference operators .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 3 : Expression DOES NOT have ``&`` operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Hence ``x[1][1][1]`` is Call By Value .. _funcs_n_ptrs_struct_td_array_ex_10: .. tab-set:: .. tab-item:: Example 2 : Call by Value : Pass Structure : \*\*\*x * Step 1 : Consider an array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 1 : Declaration has THREE dereference operators [ ], [ ] and [ ] * Step 2 : Consider an expression ``***x`` .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 2 : Expression has THREE dereference operators \*, \* and \* .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Note : ``[ ]`` and ``*`` are dereference operators .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 3 : Expression DOES NOT have ``&`` operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Hence ``***x`` is Call By Value .. _funcs_n_ptrs_struct_td_array_ex_11: .. tab-set:: .. tab-item:: Rules for Call By Reference .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has THREE dereference operators \* \* \* OR \* \* [] OR \* [] [] OR [] [] [] and * Expression has & * then it is call by reference * Example : &x[0][0][0], &x[1][2][3] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has TWO dereference operator \* \* OR [] [] OR \* [] * then it is call by reference * Example : x[0][0] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has ONE dereference operators, \* OR [ ] * then it is call by reference * Example : x[0] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow If Declaration has THREE dereference operators, and * Expression has ZERO dereference operators * then it is call by reference * Example : x .. _funcs_n_ptrs_struct_td_array_ex_12: .. tab-set:: .. tab-item:: Example 1 : Call by Reference : &x[1][1][1] * Step 1 : Consider an array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 1 : Declaration has THREE dereference operators [ ] [ ] and [ ] * Step 2 : Consider an expression ``&x[1][1][1]`` .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 2 : Expression has THREE dereference operators [ ] [ ] and [ ] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Note : ``[ ]`` and ``*`` are dereference operators .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 3 : Expression has ``&`` operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Hence ``&x[1][1][1]`` is Call By Reference .. _funcs_n_ptrs_struct_td_array_ex_13: .. tab-set:: .. tab-item:: Example 2 : Call by Reference : x[1] * Step 1 : Consider an array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 1 : Declaration has THREE dereference operators [ ] [ ] and [ ] * Step 2 : Consider an expression ``x[1]`` .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 2 : Expression has ONE dereference operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Note : ``[ ]`` and ``*`` are dereference operators .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 3 : Expression DOES NOT have ``&`` operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Hence ``x[1]`` is Call By Reference .. _funcs_n_ptrs_struct_td_array_examples_call_by_value: .. tab-set:: .. tab-item:: Examples of Call by Value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us look at examples of Call by Value .. _funcs_n_ptrs_struct_td_array_ex_15: .. tab-set:: .. tab-item:: Example 1 : Call by Value : Pass Structure : x[0][0][0], x[1][0][0], x[2][0][0] * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; * Step 2 : Pass x[0][0][0], x[1][0][0] to a function ``fun`` .. code-block:: c fun(x[0][0][0]); fun(x[1][0][0]); * Step 3 : Define function ``fun`` .. code-block:: c void fun(struct ABC y) { y.a = 777; y.b = 888; y.c = 999; } * Step 4 : Note that it is call by Value for below reason .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 1 : Declaration has THREE dereference operators [ ] [ ] and [ ] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 2 : Expression has THREE dereference operators [ ] [ ] and [ ] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 3 : Expression DOES NOT have ``&`` operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Means changing value of structure inside function DOES NOT affect value of structure in Caller ! * See full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC y) { y.a = 777; y.b = 888; y.c = 999; } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Value -----\n"); printf("x[0][0][0].a = %d\n", x[0][0][0].a); printf("x[1][0][0].a = %d\n", x[1][0][0].a); fun(x[0][0][0]); fun(x[1][0][0]); printf("----- After Call By Value -----\n"); printf("x[0][0][0].a = %d\n", x[0][0][0].a); printf("x[1][0][0].a = %d\n", x[1][0][0].a); return 0; } * Output is as below .. code-block:: c ----- Before Call By Value ----- x[0][0][0].a = 1 x[1][0][0].a = 37 ----- After Call By Value ----- x[0][0][0].a = 1 x[1][0][0].a = 37 .. _funcs_n_ptrs_struct_td_array_ex_16: .. tab-set:: .. tab-item:: Example 2 : Call by Value : Pass Structure : \*\*\*x, \*(\*(\*(x + 1) + 0) + 0) * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; * Step 2 : Pass \*\*\*x, \*(\*(\*(x + 1) + 0) + 0) to a function ``fun`` .. code-block:: c fun( ***x ); fun( *(*(*(x + 1) + 0) + 0) ); * Step 3 : Define function ``fun`` .. code-block:: c void fun(struct ABC y) { y.a = 777; y.b = 888; y.c = 999; } * Step 4 : Note that it is call by Value for below reason .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 1 : Declaration has THREE dereference operators [ ] [ ] and [ ] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 2 : Expression has THREE dereference operators \* \* and \* .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Condition 3 : Expression DOES NOT have ``&`` operator .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Means changing value of structure inside function DOES NOT affect value of structure in Caller ! * See full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC y) { y.a = 777; y.b = 888; y.c = 999; } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Value -----\n"); printf(" (***x).a = %d\n", (***x).a ); printf(" (*(*(*(x + 1) + 0) + 0)).a = %d\n", (*(*(*(x + 1) + 0) + 0)).a ); fun( ***x ); fun( *(*(*(x + 1) + 0) + 0) ); printf("----- After Call By Value -----\n"); printf(" (***x).a = %d\n", (***x).a ); printf(" (*(*(*(x + 1) + 0) + 0)).a = %d\n", (*(*(*(x + 1) + 0) + 0)).a ); return 0; } * Output is as below .. code-block:: c ----- Before Call By Value ----- (***x).a = 1 (*(*(*(x + 1) + 0) + 0)).a = 37 ----- After Call By Value ----- (***x).a = 1 (*(*(*(x + 1) + 0) + 0)).a = 37 .. _funcs_n_ptrs_struct_td_array_examples_call_by_reference: .. tab-set:: .. tab-item:: Examples of Call by Value .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Let us look at examples of Call by Reference .. _funcs_n_ptrs_struct_td_array_ex_17: .. tab-set:: .. tab-item:: Example 3 : Call by Reference : Pass Single dimension arrays which are part of a triple dimension array to a function * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow There are 6 single dimension arrays in ``struct ABC x[2][3][4]`` x[0][0] x[0][1] x[0][2] x[1][0] x[1][1] x[1][2] * Step 2.1 : Method 1 : Pass x[0][0], x[1][0] to a function ``fun`` .. code-block:: c fun( x[0][0] ); fun( x[1][0] ); * Step 2.2 : Method 2 : Pass &x[0][0][0], &x[1][0][0] to a function ``fun`` .. code-block:: c fun( &x[0][0][0] ); fun( &x[1][0][0] ); * Step 2.3 : Method 3 : Pass \*\*x, \*(\*(x + 1) + 0) to a function ``fun`` .. code-block:: c fun( **x ); fun( *(*(x + 1) + 0) ); * Step 3.1 : Define function ``fun`` .. code-block:: c void fun(struct ABC *ptr) { } * Step 3.2 : Note that it is call by Reference. Means contents of single dimension array can be changed inside function ``fun`` .. code-block:: c void fun(struct ABC *ptr) { // 1. Address of single dimension array is passed from caller // 2. We know that size of each single dimension array is 4 structures // 3. Hence, we can change access and change values of 4 structures in this function int data = 99; for (int i = 0; i < 4; i++) { ptr[i].a = data++; ptr[i].b = data++; ptr[i].c = data++; } } * See full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC *ptr) { // 1. Address of single dimension array is passed from caller // 2. We know that size of each single dimension array is 4 structures // 3. Hence, we can change access and change values of 4 structures in this function int data = 99; for (int i = 0; i < 4; i++) { ptr[i].a = data++; ptr[i].b = data++; ptr[i].c = data++; } } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Reference -----\n"); for (int i = 0; i < 4; i++) { printf("x[0][0][%d].a = %d ", i, x[0][0][i].a ); printf("x[0][0][%d].b = %d ", i, x[0][0][i].b ); printf("x[0][0][%d].c = %d ", i, x[0][0][i].c ); printf("\n"); } printf("\n"); for (int i = 0; i < 4; i++) { printf("x[1][0][%d].a = %d ", i, x[1][0][i].a ); printf("x[1][0][%d].b = %d ", i, x[1][0][i].b ); printf("x[1][0][%d].c = %d ", i, x[1][0][i].c ); printf("\n"); } // Method 1 : Access Single dimension arrays fun( x[0][0] ); fun( x[1][0] ); // Method 2 : Access Single dimension arrays fun( &x[0][0][0] ); fun( &x[1][0][0] ); // Method 3 : Access Single dimension arrays fun( **x ); fun( *(*(x + 1) + 0) ); printf("----- After Call By Reference -----\n"); for (int i = 0; i < 4; i++) { printf("x[0][0][%d].a = %d ", i, x[0][0][i].a ); printf("x[0][0][%d].b = %d ", i, x[0][0][i].b ); printf("x[0][0][%d].c = %d ", i, x[0][0][i].c ); printf("\n"); } printf("\n"); for (int i = 0; i < 4; i++) { printf("x[1][0][%d].a = %d ", i, x[1][0][i].a ); printf("x[1][0][%d].b = %d ", i, x[1][0][i].b ); printf("x[1][0][%d].c = %d ", i, x[1][0][i].c ); printf("\n"); } return 0; } * Output is as below .. code-block:: c ----- Before Call By Reference ----- x[0][0][0].a = 1 x[0][0][0].b = 2 x[0][0][0].c = 3 x[0][0][1].a = 4 x[0][0][1].b = 5 x[0][0][1].c = 6 x[0][0][2].a = 7 x[0][0][2].b = 8 x[0][0][2].c = 9 x[0][0][3].a = 10 x[0][0][3].b = 11 x[0][0][3].c = 12 x[1][0][0].a = 37 x[1][0][0].b = 38 x[1][0][0].c = 39 x[1][0][1].a = 40 x[1][0][1].b = 41 x[1][0][1].c = 42 x[1][0][2].a = 43 x[1][0][2].b = 44 x[1][0][2].c = 45 x[1][0][3].a = 46 x[1][0][3].b = 47 x[1][0][3].c = 48 ----- After Call By Reference ----- x[0][0][0].a = 99 x[0][0][0].b = 100 x[0][0][0].c = 101 x[0][0][1].a = 102 x[0][0][1].b = 103 x[0][0][1].c = 104 x[0][0][2].a = 105 x[0][0][2].b = 106 x[0][0][2].c = 107 x[0][0][3].a = 108 x[0][0][3].b = 109 x[0][0][3].c = 110 x[1][0][0].a = 99 x[1][0][0].b = 100 x[1][0][0].c = 101 x[1][0][1].a = 102 x[1][0][1].b = 103 x[1][0][1].c = 104 x[1][0][2].a = 105 x[1][0][2].b = 106 x[1][0][2].c = 107 x[1][0][3].a = 108 x[1][0][3].b = 109 x[1][0][3].c = 110 .. _funcs_n_ptrs_struct_td_array_ex_18: .. tab-set:: .. tab-item:: Example 4 : Call by Reference : Pass Address of Single dimension arrays which are part of a triple dimension array to a function * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow There are 6 single dimension arrays in ``struct ABC x[2][3][4]`` x[0][0] x[0][1] x[0][2] x[1][0] x[1][1] x[1][2] .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Address of single dimension arrays is simply &x[0][0] &x[0][1] &x[0][2] &x[1][0] &x[1][1] &x[1][2] * Step 2.1 : Method 1 : Pass address of single dimension arrays to a function ``fun`` .. code-block:: c fun( &x[0][0] ); fun( &x[1][0] ); * Step 2.2 : Method 2 : Pass address of single dimension arrays to a function ``fun`` .. code-block:: c fun( x[0] ); fun( x[1] ); * Step 2.3 : Method 2 : Pass address of single dimension arrays to a function ``fun`` .. code-block:: c fun( *x ); fun( *(x + 1) ); * Step 3.1 : Define the function ``fun`` .. code-block:: c void fun(struct ABC (*ptr)[4] ) { } * Step 3.2 : Define the function ``fun`` to change the contents of single dimension array structure by structure .. code-block:: c void fun(struct ABC (*ptr)[4] ) { (*ptr)[0].a = 66; (*ptr)[0].b = 66; (*ptr)[0].c = 66; (*ptr)[1].a = 77; (*ptr)[1].b = 77; (*ptr)[1].c = 77; (*ptr)[2].a = 88; (*ptr)[2].b = 88; (*ptr)[2].c = 88; (*ptr)[3].a = 99; (*ptr)[3].b = 99; (*ptr)[3].c = 99; } * See full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC (*ptr)[4] ) { (*ptr)[0].a = 66; (*ptr)[0].b = 66; (*ptr)[0].c = 66; (*ptr)[1].a = 77; (*ptr)[1].b = 77; (*ptr)[1].c = 77; (*ptr)[2].a = 88; (*ptr)[2].b = 88; (*ptr)[2].c = 88; (*ptr)[3].a = 99; (*ptr)[3].b = 99; (*ptr)[3].c = 99; } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Reference -----\n"); for (int i = 0; i < 4; i++) { printf("x[0][0][%d].a = %d ", i, x[0][0][i].a ); printf("x[0][0][%d].b = %d ", i, x[0][0][i].b ); printf("x[0][0][%d].c = %d ", i, x[0][0][i].c ); printf("\n"); } printf("\n"); for (int i = 0; i < 4; i++) { printf("x[1][0][%d].a = %d ", i, x[1][0][i].a ); printf("x[1][0][%d].b = %d ", i, x[1][0][i].b ); printf("x[1][0][%d].c = %d ", i, x[1][0][i].c ); printf("\n"); } // Method 1 : Access Single dimension arrays fun( &x[0][0] ); fun( &x[1][0] ); // Method 2 : Access Single dimension arrays fun( x[0] ); fun( x[1] ); // Method 3 : Access Single dimension arrays fun( *x ); fun( *(x + 1) ); printf("----- After Call By Reference -----\n"); for (int i = 0; i < 4; i++) { printf("x[0][0][%d].a = %d ", i, x[0][0][i].a ); printf("x[0][0][%d].b = %d ", i, x[0][0][i].b ); printf("x[0][0][%d].c = %d ", i, x[0][0][i].c ); printf("\n"); } printf("\n"); for (int i = 0; i < 4; i++) { printf("x[1][0][%d].a = %d ", i, x[1][0][i].a ); printf("x[1][0][%d].b = %d ", i, x[1][0][i].b ); printf("x[1][0][%d].c = %d ", i, x[1][0][i].c ); printf("\n"); } return 0; } * Output is as below .. code-block:: c ----- Before Call By Reference ----- x[0][0][0].a = 1 x[0][0][0].b = 2 x[0][0][0].c = 3 x[0][0][1].a = 4 x[0][0][1].b = 5 x[0][0][1].c = 6 x[0][0][2].a = 7 x[0][0][2].b = 8 x[0][0][2].c = 9 x[0][0][3].a = 10 x[0][0][3].b = 11 x[0][0][3].c = 12 x[1][0][0].a = 37 x[1][0][0].b = 38 x[1][0][0].c = 39 x[1][0][1].a = 40 x[1][0][1].b = 41 x[1][0][1].c = 42 x[1][0][2].a = 43 x[1][0][2].b = 44 x[1][0][2].c = 45 x[1][0][3].a = 46 x[1][0][3].b = 47 x[1][0][3].c = 48 ----- After Call By Reference ----- x[0][0][0].a = 66 x[0][0][0].b = 66 x[0][0][0].c = 66 x[0][0][1].a = 77 x[0][0][1].b = 77 x[0][0][1].c = 77 x[0][0][2].a = 88 x[0][0][2].b = 88 x[0][0][2].c = 88 x[0][0][3].a = 99 x[0][0][3].b = 99 x[0][0][3].c = 99 x[1][0][0].a = 66 x[1][0][0].b = 66 x[1][0][0].c = 66 x[1][0][1].a = 77 x[1][0][1].b = 77 x[1][0][1].c = 77 x[1][0][2].a = 88 x[1][0][2].b = 88 x[1][0][2].c = 88 x[1][0][3].a = 99 x[1][0][3].b = 99 x[1][0][3].c = 99 .. _funcs_n_ptrs_struct_td_array_ex_19: .. tab-set:: .. tab-item:: Example 5 : Call by Reference : Pass Double dimension arrays which are part of a Triple dimension array to a function * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; * Step 2 : Pass Double dimension array to function ``fun`` .. code-block:: c fun(x[1]); * Step 3.1 : Define function ``fun`` .. code-block:: c void fun(struct ABC (*ptr)[4]) { } * Step 3.2 : Access and Change structures inside function ``fun`` .. code-block:: c void fun(struct ABC (*ptr)[4]) { // 1. There are 3 single dimension arrays in one double dimension array // 2. Each single dimension array has 4 structure objects // 3. In total, 12 structures can be accessed and changed in this function int data = 66; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { ptr[0][j].a = data++; ptr[0][j].b = data++; ptr[0][j].c = data++; } ptr++; } } * Step 4 : See the full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC (*ptr)[4]) { // 1. There are 3 single dimension arrays in one double dimension array // 2. Each single dimension array has 4 structure objects // 3. In total, 12 structures can be accessed and changed in this function int data = 66; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { ptr[0][j].a = data++; ptr[0][j].b = data++; ptr[0][j].c = data++; } ptr++; } } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Reference -----\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { printf("x[1][%d][%d].a = %d ", i, j, x[1][i][j].a); printf("x[1][%d][%d].b = %d ", i, j, x[1][i][j].b); printf("x[1][%d][%d].c = %d ", i, j, x[1][i][j].c); printf("\n"); } printf("\n"); } fun(x[1]); printf("----- After Call By Reference -----\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { printf("x[1][%d][%d].a = %d ", i, j, x[1][i][j].a); printf("x[1][%d][%d].b = %d ", i, j, x[1][i][j].b); printf("x[1][%d][%d].c = %d ", i, j, x[1][i][j].c); printf("\n"); } printf("\n"); } return 0; } * Step 5 : Output is as below .. code-block:: c ----- Before Call By Reference ----- x[1][0][0].a = 37 x[1][0][0].b = 38 x[1][0][0].c = 39 x[1][0][1].a = 40 x[1][0][1].b = 41 x[1][0][1].c = 42 x[1][0][2].a = 43 x[1][0][2].b = 44 x[1][0][2].c = 45 x[1][0][3].a = 46 x[1][0][3].b = 47 x[1][0][3].c = 48 x[1][1][0].a = 49 x[1][1][0].b = 50 x[1][1][0].c = 51 x[1][1][1].a = 52 x[1][1][1].b = 53 x[1][1][1].c = 54 x[1][1][2].a = 55 x[1][1][2].b = 56 x[1][1][2].c = 57 x[1][1][3].a = 58 x[1][1][3].b = 59 x[1][1][3].c = 60 x[1][2][0].a = 61 x[1][2][0].b = 62 x[1][2][0].c = 63 x[1][2][1].a = 64 x[1][2][1].b = 65 x[1][2][1].c = 66 x[1][2][2].a = 67 x[1][2][2].b = 68 x[1][2][2].c = 69 x[1][2][3].a = 70 x[1][2][3].b = 71 x[1][2][3].c = 72 ----- After Call By Reference ----- x[1][0][0].a = 66 x[1][0][0].b = 67 x[1][0][0].c = 68 x[1][0][1].a = 69 x[1][0][1].b = 70 x[1][0][1].c = 71 x[1][0][2].a = 72 x[1][0][2].b = 73 x[1][0][2].c = 74 x[1][0][3].a = 75 x[1][0][3].b = 76 x[1][0][3].c = 77 x[1][1][0].a = 78 x[1][1][0].b = 79 x[1][1][0].c = 80 x[1][1][1].a = 81 x[1][1][1].b = 82 x[1][1][1].c = 83 x[1][1][2].a = 84 x[1][1][2].b = 85 x[1][1][2].c = 86 x[1][1][3].a = 87 x[1][1][3].b = 88 x[1][1][3].c = 89 x[1][2][0].a = 90 x[1][2][0].b = 91 x[1][2][0].c = 92 x[1][2][1].a = 93 x[1][2][1].b = 94 x[1][2][1].c = 95 x[1][2][2].a = 96 x[1][2][2].b = 97 x[1][2][2].c = 98 x[1][2][3].a = 99 x[1][2][3].b = 100 x[1][2][3].c = 101 .. _funcs_n_ptrs_struct_td_array_ex_20: .. tab-set:: .. tab-item:: Example 6 : Call by Reference : Pass address of Double dimension arrays which are part of a Triple dimension array to a function * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; * Step 2 : Pass Address of Double dimension array to function ``fun`` .. code-block:: c fun(&x[1]); * Step 3.1 : Define function ``fun`` .. code-block:: c void fun(struct ABC (*ptr)[3][4]) { } * Step 3.2 : Access and Change structures inside function ``fun`` .. code-block:: c void fun(struct ABC (*ptr)[3][4]) { int data = 666; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { (*ptr)[i][j].a = data++; (*ptr)[i][j].b = data++; (*ptr)[i][j].c = data++; } } } * Step 4 : See the full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC (*ptr)[3][4]) { int data = 666; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { (*ptr)[i][j].a = data++; (*ptr)[i][j].b = data++; (*ptr)[i][j].c = data++; } } } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Reference -----\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { printf("x[1][%d][%d].a = %d ", i, j, x[1][i][j].a); printf("x[1][%d][%d].b = %d ", i, j, x[1][i][j].b); printf("x[1][%d][%d].c = %d ", i, j, x[1][i][j].c); printf("\n"); } printf("\n"); } fun(&x[1]); printf("----- After Call By Reference -----\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { printf("x[1][%d][%d].a = %d ", i, j, x[1][i][j].a); printf("x[1][%d][%d].b = %d ", i, j, x[1][i][j].b); printf("x[1][%d][%d].c = %d ", i, j, x[1][i][j].c); printf("\n"); } printf("\n"); } return 0; } * Step 5 : Output is as below .. code-block:: c ----- Before Call By Reference ----- x[1][0][0].a = 37 x[1][0][0].b = 38 x[1][0][0].c = 39 x[1][0][1].a = 40 x[1][0][1].b = 41 x[1][0][1].c = 42 x[1][0][2].a = 43 x[1][0][2].b = 44 x[1][0][2].c = 45 x[1][0][3].a = 46 x[1][0][3].b = 47 x[1][0][3].c = 48 x[1][1][0].a = 49 x[1][1][0].b = 50 x[1][1][0].c = 51 x[1][1][1].a = 52 x[1][1][1].b = 53 x[1][1][1].c = 54 x[1][1][2].a = 55 x[1][1][2].b = 56 x[1][1][2].c = 57 x[1][1][3].a = 58 x[1][1][3].b = 59 x[1][1][3].c = 60 x[1][2][0].a = 61 x[1][2][0].b = 62 x[1][2][0].c = 63 x[1][2][1].a = 64 x[1][2][1].b = 65 x[1][2][1].c = 66 x[1][2][2].a = 67 x[1][2][2].b = 68 x[1][2][2].c = 69 x[1][2][3].a = 70 x[1][2][3].b = 71 x[1][2][3].c = 72 ----- After Call By Reference ----- x[1][0][0].a = 666 x[1][0][0].b = 667 x[1][0][0].c = 668 x[1][0][1].a = 669 x[1][0][1].b = 670 x[1][0][1].c = 671 x[1][0][2].a = 672 x[1][0][2].b = 673 x[1][0][2].c = 674 x[1][0][3].a = 675 x[1][0][3].b = 676 x[1][0][3].c = 677 x[1][1][0].a = 678 x[1][1][0].b = 679 x[1][1][0].c = 680 x[1][1][1].a = 681 x[1][1][1].b = 682 x[1][1][1].c = 683 x[1][1][2].a = 684 x[1][1][2].b = 685 x[1][1][2].c = 686 x[1][1][3].a = 687 x[1][1][3].b = 688 x[1][1][3].c = 689 x[1][2][0].a = 690 x[1][2][0].b = 691 x[1][2][0].c = 692 x[1][2][1].a = 693 x[1][2][1].b = 694 x[1][2][1].c = 695 x[1][2][2].a = 696 x[1][2][2].b = 697 x[1][2][2].c = 698 x[1][2][3].a = 699 x[1][2][3].b = 700 x[1][2][3].c = 701 .. _funcs_n_ptrs_struct_td_array_ex_21: .. tab-set:: .. tab-item:: Example 7 : Call by Reference : Pass Address of Triple Dimension array to a function * Step 1 : Consider a THREE dimensional array .. code-block:: c struct ABC { int a; int b; int c; }; struct ABC x[2][3][4]; * Step 2 : Pass Address of Triple Dimension array to a function .. code-block:: c fun(&x); * Step 3.1 : Define function ``fun`` .. code-block:: c void fun(struct ABC (*ptr)[2][3][4] ) { } * Step 3.2 : Access and change individual structures inside function ``fun`` .. code-block:: c int data = 666; for(int i = 0; i < 2; i++) { for(int j = 0; j < 3; j++) { for(int k = 0; k < 4; k++) { (*ptr)[i][j][k].a = data++; (*ptr)[i][j][k].b = data++; (*ptr)[i][j][k].c = data++; } } } * See full program below .. code-block:: c #include struct ABC { int a; int b; int c; }; void fun(struct ABC (*ptr)[2][3][4] ) { //Access and change individual structures int data = 666; for(int i = 0; i < 2; i++) { for(int j = 0; j < 3; j++) { for(int k = 0; k < 4; k++) { (*ptr)[i][j][k].a = data++; (*ptr)[i][j][k].b = data++; (*ptr)[i][j][k].c = data++; } } } } int main(void) { struct ABC x[2][3][4] = { { { {.a = 1, .b = 2, .c = 3}, {.a = 4, .b = 5, .c = 6}, {.a = 7, .b = 8, .c = 9}, {.a = 10, .b = 11, .c = 12}, }, { {.a = 13, .b = 14, .c = 15}, {.a = 16, .b = 17, .c = 18}, {.a = 19, .b = 20, .c = 21}, {.a = 22, .b = 23, .c = 24}, }, { {.a = 25, .b = 26, .c = 27}, {.a = 28, .b = 29, .c = 30}, {.a = 31, .b = 32, .c = 33}, {.a = 34, .b = 35, .c = 36}, }, }, { { {.a = 37, .b = 38, .c = 39}, {.a = 40, .b = 41, .c = 42}, {.a = 43, .b = 44, .c = 45}, {.a = 46, .b = 47, .c = 48}, }, { {.a = 49, .b = 50, .c = 51}, {.a = 52, .b = 53, .c = 54}, {.a = 55, .b = 56, .c = 57}, {.a = 58, .b = 59, .c = 60}, }, { {.a = 61, .b = 62, .c = 63}, {.a = 64, .b = 65, .c = 66}, {.a = 67, .b = 68, .c = 69}, {.a = 70, .b = 71, .c = 72}, }, }, }; printf("----- Before Call By Reference -----\n"); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 4; k++) { printf("x[%d][%d][%d].a = %d ", i, j, k, x[1][i][j].a); printf("x[%d][%d][%d].b = %d ", i, j, k, x[1][i][j].b); printf("x[%d][%d][%d].c = %d ", i, j, k, x[1][i][j].c); printf("\n"); } printf("\n"); } printf("\n"); } fun(&x); printf("----- After Call By Reference -----\n"); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 4; k++) { printf("x[%d][%d][%d].a = %d ", i, j, k, x[1][i][j].a); printf("x[%d][%d][%d].b = %d ", i, j, k, x[1][i][j].b); printf("x[%d][%d][%d].c = %d ", i, j, k, x[1][i][j].c); printf("\n"); } printf("\n"); } printf("\n"); } return 0; } * Output is as below .. code-block:: c ----- Before Call By Reference ----- x[0][0][0].a = 37 x[0][0][0].b = 38 x[0][0][0].c = 39 x[0][0][1].a = 37 x[0][0][1].b = 38 x[0][0][1].c = 39 x[0][0][2].a = 37 x[0][0][2].b = 38 x[0][0][2].c = 39 x[0][0][3].a = 37 x[0][0][3].b = 38 x[0][0][3].c = 39 x[0][1][0].a = 40 x[0][1][0].b = 41 x[0][1][0].c = 42 x[0][1][1].a = 40 x[0][1][1].b = 41 x[0][1][1].c = 42 x[0][1][2].a = 40 x[0][1][2].b = 41 x[0][1][2].c = 42 x[0][1][3].a = 40 x[0][1][3].b = 41 x[0][1][3].c = 42 x[0][2][0].a = 43 x[0][2][0].b = 44 x[0][2][0].c = 45 x[0][2][1].a = 43 x[0][2][1].b = 44 x[0][2][1].c = 45 x[0][2][2].a = 43 x[0][2][2].b = 44 x[0][2][2].c = 45 x[0][2][3].a = 43 x[0][2][3].b = 44 x[0][2][3].c = 45 x[1][0][0].a = 49 x[1][0][0].b = 50 x[1][0][0].c = 51 x[1][0][1].a = 49 x[1][0][1].b = 50 x[1][0][1].c = 51 x[1][0][2].a = 49 x[1][0][2].b = 50 x[1][0][2].c = 51 x[1][0][3].a = 49 x[1][0][3].b = 50 x[1][0][3].c = 51 x[1][1][0].a = 52 x[1][1][0].b = 53 x[1][1][0].c = 54 x[1][1][1].a = 52 x[1][1][1].b = 53 x[1][1][1].c = 54 x[1][1][2].a = 52 x[1][1][2].b = 53 x[1][1][2].c = 54 x[1][1][3].a = 52 x[1][1][3].b = 53 x[1][1][3].c = 54 x[1][2][0].a = 55 x[1][2][0].b = 56 x[1][2][0].c = 57 x[1][2][1].a = 55 x[1][2][1].b = 56 x[1][2][1].c = 57 x[1][2][2].a = 55 x[1][2][2].b = 56 x[1][2][2].c = 57 x[1][2][3].a = 55 x[1][2][3].b = 56 x[1][2][3].c = 57 ----- After Call By Reference ----- x[0][0][0].a = 702 x[0][0][0].b = 703 x[0][0][0].c = 704 x[0][0][1].a = 702 x[0][0][1].b = 703 x[0][0][1].c = 704 x[0][0][2].a = 702 x[0][0][2].b = 703 x[0][0][2].c = 704 x[0][0][3].a = 702 x[0][0][3].b = 703 x[0][0][3].c = 704 x[0][1][0].a = 705 x[0][1][0].b = 706 x[0][1][0].c = 707 x[0][1][1].a = 705 x[0][1][1].b = 706 x[0][1][1].c = 707 x[0][1][2].a = 705 x[0][1][2].b = 706 x[0][1][2].c = 707 x[0][1][3].a = 705 x[0][1][3].b = 706 x[0][1][3].c = 707 x[0][2][0].a = 708 x[0][2][0].b = 709 x[0][2][0].c = 710 x[0][2][1].a = 708 x[0][2][1].b = 709 x[0][2][1].c = 710 x[0][2][2].a = 708 x[0][2][2].b = 709 x[0][2][2].c = 710 x[0][2][3].a = 708 x[0][2][3].b = 709 x[0][2][3].c = 710 x[1][0][0].a = 714 x[1][0][0].b = 715 x[1][0][0].c = 716 x[1][0][1].a = 714 x[1][0][1].b = 715 x[1][0][1].c = 716 x[1][0][2].a = 714 x[1][0][2].b = 715 x[1][0][2].c = 716 x[1][0][3].a = 714 x[1][0][3].b = 715 x[1][0][3].c = 716 x[1][1][0].a = 717 x[1][1][0].b = 718 x[1][1][0].c = 719 x[1][1][1].a = 717 x[1][1][1].b = 718 x[1][1][1].c = 719 x[1][1][2].a = 717 x[1][1][2].b = 718 x[1][1][2].c = 719 x[1][1][3].a = 717 x[1][1][3].b = 718 x[1][1][3].c = 719 x[1][2][0].a = 720 x[1][2][0].b = 721 x[1][2][0].c = 722 x[1][2][1].a = 720 x[1][2][1].b = 721 x[1][2][1].c = 722 x[1][2][2].a = 720 x[1][2][2].b = 721 x[1][2][2].c = 722 x[1][2][3].a = 720 x[1][2][3].b = 721 x[1][2][3].c = 722 .. card:: See Also * Other topics of structure and functions * :doc:`./struct` * :doc:`./struct_sd_array` * :doc:`./struct_dd_array` * :doc:`./struct_td_array` * :doc:`./struct_sp` * :doc:`./struct_dp` * :doc:`./struct_tp` * Current Module * :doc:`../funcs_n_ptrs` * Previous Module * :doc:`../../typecasting_n_ptr/typecasting_n_ptr` * Next Module * :doc:`../../memcpy_ptr/memcpy_ptr` * Other Modules * :doc:`../../variable_and_ptr/variable_and_ptr` * :doc:`../../array_n_ptrs/array_n_ptrs` * :doc:`../../malloc_ptr/malloc_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:`../../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`