本文介绍了如何在C中将uint8_t值数组转换为十六进制转储字符字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将字节数组 uint8_t
转换为char数组字符串(**相同值而不是ASCII ),然后简单地打印此字符串数组如下:
I want to convert byte array uint8_t
Hexadecimal values to char array string (**same values not ASCII) and then simple print this string array as below:
输入:
uint8_t myarr[4]={0x11,0x12,0x33,0x1A}
输出:
1112331A
简单字符数组字符串,而不是十六进制数组字符串。
Simple char array string not hexadecimal array string.
推荐答案
只需循环数组的元素,然后使用 printf
即可使用%hhx
格式说明符打印每个元素。
Just loop over the elements of the array and use printf
to print each element using the "%hhx"
format specifier.
还请注意,这些值不会存储为十六进制。十六进制只是表示值的一种形式。
Also note that the values will not be stored as hexadecimal. Hexadecimal is just a form to present values.
这篇关于如何在C中将uint8_t值数组转换为十六进制转储字符字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!