我有一个字符串
char value[16]="ffffffffc06e91"
我需要检索以字符串形式存储在变量值中的地址。
即..
void * ptr = NULL;
somefunction(value,ptr); // ptr = 0xffffffffc06e91
有这样的功能或方法吗?
谢谢
最佳答案
不要使用atoi()
; int
值可能不够大,无法存储该值,并且该函数无法处理十六进制字符串。
使用strtoll()
相反:
void *ptr = (void*)strtoll("ffffffffc06e91", NULL, 16);
关于c - 检索存储为字符串的地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53402324/