I have following function:
void hexDump(char *buf, size_t size) {
for(int i = 0; i < size; i++) {
if(i % 4 == 0) {
printf("\n");
}
printf("%02x ", buf[i]);
}
The first two lines always output fine, but the next lines break:
24 00 00 00
00 0a 04 04
ffffffe8 ffffffd9 22 63
00 00 00 00
02 00 0a 00
...
Real content of buf obtained by gdb:
0x7fffffffd320: 0x24 0x00 0x00 0x00 0x00 0x0a 0x04 0x04
0x7fffffffd328: 0xe8 0xd9 0x22 0x63 0x00 0x00 0x00 0x00
0x7fffffffd330: 0x02 0x00 0x0a 0x00 0x00 0x00 0x00 0x00
How can I fix it?