我需要在变量中存储64位内存地址,a long
应该足够大以容纳该值。
例如:
long arr[2];
//store the memory address of arr[1] in arr[0]
arr[0] = (long)(arr + 1);
printf("arr[0]: 0x%012x Actual address: %p\n", arr[0], (void *)arr);
Run Code Online (Sandbox Code Playgroud)
输出:
arr[0]: 0x00007c6a2c20, Actual address: 0x7ffe7c6a2c20
Run Code Online (Sandbox Code Playgroud)
存储在中的值arr[0]
似乎被截断了。
我在这里想念什么?