printf("%x", ...)
expects an int
argument and you are giving it a char *
, i.e. a pointer. That is undefined behaviour.
What you probably meant is
printf("%02hhx%02hhx%02hhx%02hhx\n", array[0], array[1], array[2], array[3]);
to print the first 4 characters as hexadecimal numbers. (Thanks to @chux for reminding
me about the "hh" modifier, which specifies that the conversion applies to a signed or unsigned char
argument.)
(But note that "FFD8" is the hexadecimal notation for two bytes: 0xFF, 0xD8.)