#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
typedef int Status[3];
int a[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
a[i][j] = i*3 + j + 1;
}
}
Status &b = a[0]; //1 2 3
Status &c = a[1]; //4 5 6
Status &d = a[2]; //7 8 9
//test memcmp 比较 b, c元素 1.b > c: 1 , 2.b == c: 0, 3.b < c: -1
cout << memcmp(b, c, sizeof(c)) << endl;
//test memcpy, 将 c数组元素都拷贝到d中
memcpy(&d, &c, sizeof(c));
for (int i = 0; i < 3; i++) {
cout << d[i] << " ";
}
for (int i = 0; i < 3; i++) {
cout << a[2][i] << " "; //同时也改变了 a[2]这行数据
}
//这两个函数,完成整块内存的比较和复制, 比循环比较和赋值要快
}