#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#define BUFFER_SIZE 1024

int main(int argc, char *argv[])
{
    FILE *f;
    char buffer[BUFFER_SIZE];
    int bytesRead;
    int i;
    
    f = fopen(argv[1], "rb");

    do {
        bytesRead = fread(buffer, sizeof(char), BUFFER_SIZE, f);
        for(i = 0; i < bytesRead; i++) {
            printf("%.4x '%c'\n", (unsigned char) buffer[i], 
                                  (unsigned char) buffer[i] > 32 && (unsigned char) buffer[i] < 127 ? buffer[i] : ' ');
        }
    } while(bytesRead != 0);

    return 0;
}
