Originally Posted by
Click_here
I'm proposing that by forcing the programmer to dereference a pointer to get its value, you are reminding everyone that it is a pointer. Isn't that a good thing?
And indeed multip[i][j] dereferences the pointer named multip. The point here is that the conversion of an array to a pointer to its first element is canonical in C. Trying to avoid that by passing a pointer to the array rather than the array itself (and hence a pointer to its first element) is unusual and complicates the syntax unnecessarily.
If you really want to avoid this, then I would say that the proper thing to do is to encapsulate the 2D array in a struct:
Code:
struct click_here_type
{
int x[5][5];
};
void click_here_print_element(const struct click_here_type *click_here, size_t i, size_t j)
{
printf("%d", click_here->x[i][j]);
}
/* ... */
click_here_type click_here;
/* ... */
click_here_print_element(&click_here, 1, 1);
Originally Posted by
Click_here
What are the disadvantages of treating a pointer to a 2D array like a pointer to a 2D array?
There are no disadvantages in doing that. Rather, the disadvantage is in having a pointer to a 2D array when a pointer to a 1D array will suffice.