//online parser:
https://www.bccn.net/run/
程序代码:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int a[3][2];
int b[2][3];
int i, j;
for (i = 0; i <= 2; i++)
for (j = 0; j <= 1; j++)
#define V_DBG
#ifndef V_DBG
/* scanf("%d ",&a[i][j]); */
#else
//set value->a
a[i][j] = i * 10 + j;
#endif
//print->a
for (i = 0; i <= 2; i++)
for (j = 0; j <= 1; j++)
printf("a[%d][%d] = %d\t", i, j, a[i][j]);
puts("");
//dup a->b
memcpy(b, a, sizeof(a));
//print->b
for (i = 0, argv[0] = (char *)&b; i < 2 * 3; i++)
printf("b[%d] = %d\t", i, ((int *)argv[0])[i]);
return 0;
}
output sample:
a[0][0] = 0
a[0][1] = 1
a[1][0] = 10
a[1][1] = 11
a[2][0] = 20
a[2][1] = 21
b[0] = 0
b[1] = 1
b[2] = 10
b[3] = 11
b[4] = 20
b[5] = 21
[此贴子已经被作者于2021-10-27 21:42编辑过]