In this approach, we simply dynamically allocate one huge block of memory of size M N and assign it to the pointer. Then we may index the 2D array using pointer arithmetic. In C, a 2D array can be dynamically allocated using a single pointer. This means that malloc allocates a memory block of size row*column*dataTypeSize, and pointer arithmetic can be used to retrieve the matrix elements.
Vishalini.R Answered question June 28, 2023