gpt4 book ai didi

c - 如何将文字 char 十六进制值转换为十六进制值本身?

转载 作者:太空宇宙 更新时间:2023-11-04 08:54:01 27 4
gpt4 key购买 nike

我有应该存储在 unsigned char[64] 数组中的文字值。如何将此类值转换为等效的十六进制值?

int main() {

unsigned char arry[1] = { 0xaa }

char* str = "fe"; //I want to store 0xfe on arry[0]

arry[0] = 0xfe; // this works, but I have to type it
arry[0] = 0x + str; //obviously fails

return 0;
}

有什么建议吗?

最佳答案

arr[0] = strtol(str,NULL,16);  // If one entry is big enough to hold it.

关于c - 如何将文字 char 十六进制值转换为十六进制值本身?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18260327/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com