有什么可以直接调用的函数吗,求大神告知
hahaha33:
打错了,是如何把16进制数据转换成字符串
YiKai Chen:
回复 hahaha33:
用sprintf
hahaha33:
回复 YiKai Chen:
谢谢解答
xyz549040622:
c标准库中的格式化输出函数sprintf
Alvin Chen:
除了上面的标准库
还可以参考:
/********************************************************************** @fnUtil_convertBdAddr2Str** @briefConvert Bluetooth address to string. Only needed when*LCD display is used.** @parampAddr – BD address** @returnBD address as a string*/
char *Util_convertBdAddr2Str(uint8_t *pAddr)
{uint8_tcharCnt;charhex[] = "0123456789ABCDEF";static char str[(2*B_ADDR_LEN)+3];char*pStr = str;
*pStr++ = '0';*pStr++ = 'x';
// Start from end of addrpAddr += B_ADDR_LEN;
for (charCnt = B_ADDR_LEN; charCnt > 0; charCnt–){*pStr++ = hex[*–pAddr >> 4];*pStr++ = hex[*pAddr & 0x0F];}*pStr = NULL;
return str;
}