gpt4 book ai didi

c++ - 字符串到字节数组

转载 作者:太空宇宙 更新时间:2023-11-04 00:56:11 24 4
gpt4 key购买 nike

如何输入 DEADBEEF 并输出 DE AD BE EF 作为四字节数组?

最佳答案

void hexconvert( char *text, unsigned char bytes[] )
{
int i;
int temp;

for( i = 0; i < 4; ++i ) {
sscanf( text + 2 * i, "%2x", &temp );
bytes[i] = temp;
}
}

关于c++ - 字符串到字节数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2575468/

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