#include /* HEX standard input to standard output */ void HEX_digit(short di); main(int argc, char *argv[]) { short c; short hi, low; short nl; FILE *file; if(argc!=2) {printf("Opps!\n");return;} file=fopen(argv[1],"r"); if(file==0) {printf("File %s failed to open.\n",argv[1]);return;} nl=0; while ( (c=getc(file))!=EOF ) { hi=c/16;low=c-16*hi; HEX_digit(hi);HEX_digit(low); nl++; if(nl>15) { nl=0; putchar('\n');} else putchar(' '); } putchar('\n'); fclose(file); } void HEX_digit(short di) { if(di>9) putchar('a'-10+di); else putchar('0'+di); }