You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
voidprint_hexadecimal(unsignedchar *ptr, size_t len) {
for (size_t i = 0; i < len; i++)
printf("%02x ", ptr[i]);
putchar('\n');
}
// more generic one// `in` is the pointer of the structure// `len` is the byte length of the structurevoidprint_hexadecimal(constvoid *in, size_t len) {
unsignedlonglong *ptr = (unsignedlonglong *)in;
// convert length in one-byte data-type to length in long longsize_t cell_len = sizeof(longlong);
len = (len + cell_len - 1) / cell_len;
for (size_t i = 0; i < len; i++)
printf("%016llx ", ptr[i]);
putchar('\n');
}
// output in 32 byte lengthvoidprint_hexadecimal(constvoid *in, size_t len) {
unsigned __INT32_TYPE__ *ptr = (unsigned __INT32_TYPE__ *)in;
// convert length in one-byte data-type to length in long longsize_t cell_len = sizeof(__INT32_TYPE__);
len = (len + cell_len - 1) / cell_len;
for (size_t i = 0; i < len; i++)
printf("%08x ", ptr[i]);
putchar('\n');
}