home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- int main (int argc, char **argv)
- {
- FILE *in, *out;
- unsigned char a[8];
- int i, c;
-
- if (argc!=3)
- {
- fprintf (stderr, "usage: bin2inc source destination\n");
- exit (1);
- }
-
- if (!(in=fopen(argv[1],"rb")))
- {
- fprintf (stderr, "error: can't open %s.\n", argv[1]);
- exit (1);
- }
-
- if (!(out=fopen(argv[2],"wt")))
- {
- fclose (in);
- fprintf (stderr, "error: can't create %s.\n", argv[2]);
- exit (1);
- }
-
- while ((c=fread(a,1,8,in))!=0)
- {
- fprintf (out, "\t\tdb\t");
- for (i=0; i<c-1; i++)
- fprintf (out, "%03xh, ", a[i]);
- fprintf (out, "%03xh\n", a[i]);
- }
-
- fclose (out);
- fclose (in);
- return 0;
- }
-