简体   繁体   中英

Convert hex numbers from unsigned char to string

I have an array of unsigned chars with hex values and I need to make a string of them. So when I have arr[0]=2b and arr[1]=fc I want to be able to make a string s="2bfc" , not the characters from ascii codes. How can I do that?

You could change to long or int and loop through adding +arr[ArrayIndex]*0x10^ArrayIndex to get one int representation of it using itoa() , then convert the int to a literal string of it. Just to outline a manual process of doing it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM