我有以下字符数组:
char hex[16] = "0x7fffa410c240"
我如何将它转换成可以分配给另一个变量的数字地址。 重要的是我必须保持值(value)的基础保持不变,即 16(十六进制)。 提前致谢。
最佳答案
尝试函数 strtoull
返回 unsigned long long
。
在 Visual Studio 上 strtoull
不可用,但是 _strtoui64
大概可以用。
编辑
作为R..在评论中提到你应该使用 sscanf(hex, "%p", ..)
或 strtoumax
与 strtoull
具有相同的原型(prototype)但返回一个 uintmax_t
。
关于c - 如何将存储在char数组中的地址转换为实际地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7514546/