Skip to content

Instantly share code, notes, and snippets.

Last active Dec 13, 2017
What would you like to do?
Simple file viewer in hex format. usage: hexview <filename>
// hexview.c
// Author: FarooqKZ
// It's free software under GPL3+ and comes WITHOUT ANY WARRENTY FROM MAIN AUTHOR
#include <stdio.h>
int main(int argc, char *argv[]){
if (argc == 1 || !strcmp(argv[1], "-h")){
printf("Usage: hexview file_path\n");
return 0;
FILE *fs = fopen(argv[1], "r");
long byte_number = 0;
if ((++byte_number % 26) == 0) // goes to new line each 26 bytes
printf("\n"); // you may remove this part and then use fold to split it into lines
int t = getc(fs);
if (t == EOF)
printf("%.2X ", t);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment