I am trying to convert an array to hex, and then put it in a string variable. In the next loop, printf works fine, but I can't use sprintf correctly. How can I fill in the hexadecimal values in the array as ASCII?
static unsigned char digest[16];
static unsigned char hex_tmp[16];
for (i = 0; i < 16; i++) {
printf("%02x",digest[i]); <--- WORKS
sprintf(&hex_tmp[i], "%02x", digest[i]); <--- DOES NOT WORK!
}
Dberg source
share