指针问题求指教
下面的程序为什么会出错?还有怎么用二维指针调用二维数组?#include <stdio.h>
void exchange(int **a, int **b, int M, int N)
{
int mid[M][N],i,j;
for (i = 0;i < M;i++)
{
for (j = 0; j < N;j++)
{
mid[i][j] = a[i][j];
a[i][j] = b[i][j];
b[i][j] = mid[i][j];
}
}
}
int main()
{
int i,j,g,h;
scanf ("%d %d",&g,&h);
int arr[g][h],brr[g][h];
for (i = 0;i < g;i++)
{
for (j = 0;j < h;j++)
{
scanf ("%d",&arr[i][j]);
}
}
for (i = 0;i < g;i++)
{
for (j = 0;j < h;j++)
{
scanf ("%d",&brr[i][j]);
}
}
exchange((int**)arr,(int**)brr,g,h); //我觉得是这里出了问题
for (i = 0;i < g;i++)
{
for (j = 0;j < h;j++)
{
printf ("%d",arr[i][j]);
}
printf ("\n");
}
for (i = 0;i < g;i++)
{
for (j = 0;j < h;j++)
{
printf ("%d",arr[i][j]);
}
printf ("\n");
}
system ("pause");
return 0;
}