#include int main(argc,argv) int argc ; char *argv[] ; { FILE *fopen(), *fpin, *fpout; long x; int i; if (argc != 3) { fprintf(stderr, "\ chnghex: usage: chnghex \n\n\ where is a space separated ascii file of integers (longs)\n\ and is an ascii file of hexidecimal numbers corresponding\n\ to and having 10 numbers per a line (80 characters per line).\n"); exit(1); } if ((fpin = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "%s can not be opened for reading\n",argv[1]); exit(1); } if ((fpout = fopen(argv[2], "w")) == NULL) { fprintf(stderr, "%s can not be opened for writing\n",argv[2]); exit(1); } i = 0; while (fscanf(fpin, "%ld", &x) != EOF) { i++; if (fprintf(fpout, "%08x", x) < 0) { fprintf(stderr, "error on writing to %s\n",argv[2]); } if (i==10) { fprintf(fpout, "\n"); i = 0; } } fclose(fpin); fclose(fpout); }