二维数组变量赋值二维数组内存
程序代码:
int col; int row; float f[4][4] = { {1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16} }; col = 4; row = 4; // 申请内存 float** Rmatrix = (float**)malloc(sizeof(float*) * col); for (int i = 0; i < col; i++) { Rmatrix[i] = (float*)malloc(sizeof(float) * row); } // 赋值 Rmatrix = f; for (int i = 0; i < col; i++) { for (int j = 0; j < row; j++) { printf(" %f ", Rmatrix[i][j]); } putchar('\n'); }
错误如下:
使用VS2019写的,
请问为什么呢?