
#include <stdio.h>

int main(int argc, char *argv[])
{
    FILE *f;
    int i = 0, c;
    long int j=0;
    if (argc != 2)
    {   printf("hexdump <file>\n");
        return 0;
    }
    f = fopen(argv[1], "rb");
    if (f == NULL)
    {   printf("File %s not found\n", argv[1]);
        return 0;
    }
    while ((c = getc(f)) != EOF)
    {   if (i == 0) printf("%.6x: ", j), j+=16;
        printf("%.2x ", c & 0xff);
        i++;
        if (i == 15) printf("\n"), i=0;
    }
    if (i != 0) printf("\n");
    return 0;
}
