diff options
Diffstat (limited to '24_read_arr3/test.c')
-rw-r--r-- | 24_read_arr3/test.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/24_read_arr3/test.c b/24_read_arr3/test.c new file mode 100644 index 0000000..c91dcfb --- /dev/null +++ b/24_read_arr3/test.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <stdlib.h> + +int* aFunction(int x, int *p, int ** q) { + printf("x = %d\n", x); + printf("*p = %d\n", *p); + printf("**q= %d\n", **q); + *p = 42; + **q = 99; + *q = &p[1]; + return &p[2]; +} + +int main (void) { + int anArray[3][3] = { {1,2,3}, + {4,5,6}, + {7,8,9} }; + + int * p = anArray[1]; + int * q = aFunction(anArray[0][0], + anArray[2], + &p); + for (int i =0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + printf("%d\n", anArray[i][j]); + } + } + printf("*q=%d\n", *q); + + return EXIT_SUCCESS; +} |