【发布时间】:2018-05-23 04:59:20
【问题描述】:
int y = 1;
int *x = &y;
printf("%p\n",x); // instead of printing, get this into variable of type unintptr_t
我想将地址x 放入uintptr_t 类型的变量中
有没有办法在 C 中做到这一点?
【问题讨论】:
-
我错过了什么?
uintptr_t ptr = (uintptr_t)x;? -
如果不重复,则与 stackoverflow.com/q/18545212/694576 相关。
-
@John3136n
(uintptr_t)x;缺少通过void*所需的演员表。
标签: c pointers casting type-conversion