Passing 2D arrays in C like argv of main
c, pointers
Solution
An array name when passed to a function will decay to the value of the address of its first element, and its type will be a pointer to that element type. Since the type of `multi[0]` is a `char[10]`, then `multi` will decay `pointer to char[10]`.
`main()` receives an array of pointers to `char` in its second parameter, which is why `argv` can be `char **argv` or `char *argv[]`.
Problem
I am learning passing 2D arrays to functions in C and learned that I can receive 2D array in the function as following: - `void test(char a[5][10])` - `void test(char (*a)[10])` Above declarations work for me but looking on `**argv` parameter of function main I thought of changing my function to `void test(char **a)`. But this does not work correctly. I do not understand why. Please explain. Here is my code ``` #include<stdio.h> int main(int argc, char **argv){ char multi[5][10] = { {'0','0','2','3','4','5','6','7','1','9'}, {'a','b','c','d','e','f','g','h','i','j'}, {'A','B','C','D','E','F','G','H','I','J'}, {'9','8','7','6','5','4','3','2','1','0'}, {'J','I','H','G','F','E','D','C','B','A'} }; test(multi); return 0; } void test(char (*a)[10]) // void test(char **a) does not work { printf("\n a[2][1] is: %d",*(*(a + 2)+1)); } ```