Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Geoffrey McRae gnif

🏠
Working from home
View GitHub Profile
@ccbrown
ccbrown / DumpHex.c
Last active May 5, 2021
Compact C Hex Dump Function w/ASCII
View DumpHex.c
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];