- #include<iostream>
- using namespace std;
- int main()
- {
- char *a;
- int *b;
- a = (char *)malloc(4);
- a[0] = 0;
- a[1] = 4;
- a[2] = 0;
- a[3] = 0;
- cout << a << endl;
- b = (int *)a;
- cout << *b << endl;
- system("pause");
- }
结果为1024,即 00 00 04 00
int4字节与char数组顺序相反,char为00 04 00 00