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));
}