Tag: uint

在C中打印void *变量

大家好我想用printf进行调试。 但我不知道如何打印“out”变量。 在返回之前,我想打印此值,但其类型为void *。 int hexstr2raw(char *in, void *out) { char c; uint32_t i = 0; uint8_t *b = (uint8_t*) out; while ((c = in[i]) != ‘\0’) { uint8_t v; if (c >= ‘0’ && c = ‘A’ && c = ‘a’ || c <= 'f') { v = 10 + c – 'a'; } […]

如何将char转换为以uint8_tforms存储的hex?

假设我有这些变量, const uint8_t ndef_default_msg[33] = { 0xd1, 0x02, 0x1c, 0x53, 0x70, 0x91, 0x01, 0x09, 0x54, 0x02, 0x65, 0x6e, 0x4c, 0x69, 0x62, 0x6e, 0x66, 0x63, 0x51, 0x01, 0x0b, 0x55, 0x03, 0x6c, 0x69, 0x62, 0x6e, 0x66, 0x63, 0x2e, 0x6f, 0x72, 0x67 }; uint8_t *ndef_msg; char *ndef_input = NULL; 如何将ndef_input (只是一个纯文本,如“hello”)转换为hex并保存到ndef_msg ? 如您所见, ndef_default_msg是hexforms。 ndef_msg数据ndef_msg应该是这样的。 有点背景,在原始程序( 源代码 )中,程序将打开一个文件,获取数据并将其放入ndef_msg […]