我有一些数据存储在一个大小为M的一维数组中。现在我需要将它视为一个二维数组,其维数为NxP,其中N和P的乘积等于M。我只知道运行时的N和P值。如何在C语言中实现这样的函数?
int array[M]; /* one dimensional array where some data is stored*/
int** newArray; /* the dimension of newArray should be NxP such that we can access the data in 'array' as a two-dimensional array*/