2维数组作为实参时的问题((*b)[5]传到函数 print里面直接乱码)
#include<stdio.h>int main()
{
double a[3][5] = { {1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15} };
void print(double p[][5]);
double* copy_1(double a[][5]);
double(*b)[5] = copy_1(a);
print(b);
}
double* copy_1( double a[][5])
{
int i, j;
double cop[3][5];
for (i = 0; i < 3; i++)
{
for (j = 0; j < 5; j++)
{
cop[i][j] = a[i][j];
}
}
return cop;
}
void print(double (*p)[5])
{
int i, j;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 5; j++)
printf("p[%d][%d] = %.1lf ",i,j,p[i][j]);
printf("\n");
}
}