https://stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function
The major reason for problems when passing regular arrays, 1D or 2D or more, the array devolves into pointers, the function has no clue what the array dimensions are.
There are several different suggested ways to pass that 2D array, the method I see most common is:
void passFunc(int A[][8], int row_size)
And you pass the array's first dimension 4 as the second parameter, the 2nd dimension of the array is explicitly coded in the function's parameter list.
I personally would do one of three things (not necessarily in the order of what works best):
1. create a temp 1D array to hold the 2D array, passing that array and the 2D dimensions into the function.
void passFunc(int A_temp[], int row_size, int col_size)
2. upgrade the function to be a template function so the 2D dimensions are automatically passed to the function without being explicit parameters which need to be passed when calling the function.
3. create a temp stdlib 2D container, a vector of vectors, to hold the array's elements and pass the vector into the function. The vector doesn't devolve to a pointer and you can query each contained vector for its size.
C++20 added std::span to the toolbox which allows passing a 1D array or other container.
https://en.cppreference.com/w/cpp/container/span
I freely admit I am not all that conversant with std::span, I have yet to use it in any code I write other than brief testing snippets.
C++23 added std::mdspan to the toolbox, I am even less knowledgeable about this as I am std::span.
https://en.cppreference.com/w/cpp/container/mdspan
At first glance IMO this looks horribly complex and not at all intuitive as dealing with actual true multi-dimensional containers.
https://stackoverflow.com/questions/75778573/what-is-an-mdspan-and-what-is-it-used-for