blob: 4d8a7bc13ac3c3fcdb808a39d00513f9a8af80fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <stdio.h>
// Print the "length" data values, starting at addr, as hex values.
void print_data(void *addr, unsigned int length) {
unsigned char *p = (unsigned char *) addr;
unsigned int line_chars = 0;
if (length == 0) length = 16;
for (; length > 0; p++, length--) {
line_chars += printf("%02x", (unsigned int) *p);
if (line_chars > 75) {
printf("\n");
line_chars = 0;
} else {
printf(" ");
line_chars++;
}
}
printf("\n");
}
// Trivial test:
// main() {
// char s[100] = " ACDabcd1asdfjklsajdfklsadjfklsadjfklsajfaklsfjsaklf";
// print_data(s, 50);
// }
|