When you create the multi-dimensional array char a[10][10], according to my book it says you must use a parameter similar to char a[][10] to pass the array to a function.
Why must you specify the length as such? Aren’t you just passing a double pointer to being with, and doesn’t that double pointer already point to allocated memory? So why couldn’t the parameter be char **a? Are you reallocating any new memory by supplying the second 10.
Pointers are not arrays
A dereferenced
char **is an object of typechar *.A dereferenced
char (*)[10]is an object of typechar [10].Arrays are not pointers
See the c-faq entry about this very subject.
Assume you have
and, for the sake of argument, both point to the same place: 0x420000.
and this is why the argument cannot be of type
char**. Alsochar**andchar (*)[10]are not compatible types, so the types of arguments (the decayed array) must match the parameters (the type in the function prototype)