fully dynamic arrays
I am trying to build a fully dynamic 2D array in C, where the number of rows and columns is determined at runtime. I used calloc to allocate each row, so I expected that all elements would be initialized to 0. When I pass my fully dynamic array (int **grades) to a printing function that expects int **, the output is indeed all zeros, as expected. However, when I try to pass the same dynamic array to a function declared as void print_grades(int grades[][NUM_OF_CLASSES], int n_rows, int n_cols), I expected it to decay to int ** and also print zeros, but instead I get strange, seemingly garbage values. Why does the output differ in this case? How does C handle the difference between a pointer-to-pointer (int **) and a 2D array (int[][NUM]) when passing them to functions? https://www.sololearn.com/en/compiler-playground/c6bN8FuNgQXV