更新时间:2022-10-15 11:54:36
It appears that the %X
specifier is expecting an int
-sized input to be passed, while you seem to be passing it an unsigned char
(isn't that what uuid[i]
is?).
Try doing this and see if it helps:
for (int i = 0; i < 16; i++) {
int temp = uuid[i];
printf("%02X", temp);
}
printf("\n");
OK, I looked at it more carefully after reading Matthew's answer.
The issue is memcpy
along with the (unknown) type of uuid
. You copy the uint
s over uuid
. The first 4 bytes of uuid
are the little-endian representation of data[0]
, as should be expected.
Now one theory that could explain the rest is that uint32
is actually 8 bytes long instead of 4, so when you copy the first 16 bytes of data
onto uuid
we see in order:
data[0]
, little endiandata[0]
(junk)data[1]
, little endiandata[1]
(junk, for some reason all zeroes)data[2]
and data[3]
.So what is sizeof(uint32)
equal to?