when we pass a 2D array as arguments to functions, which it does not have to be specified in most dimensions. The key point here is that any changes made to functions that change are reflected in the calling functions, because when we pass a two-dimensional array as arguments, it means that the functions actually take a pointer to a 1-D array. And the size of this number of columns. examples
1 - int funct(int (*a) [4]);
here a is a pointer to an array of integers. we can just go the same way
2- void funct(int a[][4]);
as I said earlier, I left most always optional. In the first example, the size of a will be 4, because it is usually just a pointer. while * a size will be 16, because we have 4 columns, and for each column we have 4 bytes, so 4 * 4 = 16 bytes.
But the most preferred way is always to use dynamic memory allocations.
I hope you can make it.
Anup Raj Dubey Mar 14 '16 at 18:36 2016-03-14 18:36
source share