#include <iostream> using namespace std; int main(){ short int arr[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int* p = (int*)arr; for(; p <= ((int*)(&arr[10])); ++p){ cout << "*p = " << *p << endl; } return 0; }
0 1 2 3 4 5 6 7 8 9
在内存中存储方式
- 0001 0000 0003 0002 0005 0004 .....
- 设计到内存时,要注意到大端小端的区别
- 输出4个字节
- 1 * 16 ^ 4 + 0 = 65556
时间: 2024-11-10 07:44:10