Printing leading zeroes for hexadecimal in C

Solution 1:

Use "%02x".

The two means you always want the output to be (at least) two characters wide.

The zero means if padding is necessary, to use zeros instead of spaces.

Solution 2:

result is a pointer, use a loop to print all the digits:

int i;
for (i = 0; i < 16; i++) {
   printf("%02x", result[i]);
}