【二维数组全部copy】
#include<stdio.h>
#define ROWS 3
#define COLS 4
void cpoy_arry(double source [][COLS], double arry [][COLS], int m,int n);
int main()
{
double source[][COLS] = { {1.1,2.2,3.3,0},{4.4,5.5,6.6,0},{7.7,8.8,9.9,0}};
double arry[ROWS][COLS] = { 0 };
cpoy_arry(source,arry,ROWS,COLS);
for (int i = 0; i < ROWS; i++)
{
for (int j = 0; j < COLS; j++)
{
printf("%8.3lf ", arry[i][j]);
}
putchar('\n');
}
putchar('\n');
getchar();
getchar();
return 0;
}
void cpoy_arry(double source[][COLS], double arry[][COLS], int m,int n)
{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
*(*(arry + i) + j) = *(*(source + i) + j);
}
}
}
网友评论