#include <dos.h>
#include <stdio.h>
#include <dir.h>
#include <string.h>
void main(int ParamCount,char *ParamStr[]){
struct ffblk  blk;
char drive[MAXDRIVE], dir[MAXDIR], file[MAXFILE], ext[MAXEXT+1];
int lv;
FILE *s,*d;
unsigned char c;
//---------------------------- Help -----------------------------------------
if(ParamCount!=2){printf(
    "\tEinTool, das Binäre Dateien in C++ HexFeld umwandelt\n"
    "\tEin Programm von Dave Sun (C) 1995\n"
    "\tEingabe bin2Hex.exe FileName.EXT\n");return;}
//--------------------------- FileUntersuchung ------------------------------

fnsplit(ParamStr[1],drive,dir,file,ext);
ext[0]='.';ext[1]='H';ext[2]='E';ext[3]='X';ext[4]='\0';
if((s=fopen(ParamStr[1],"rb"))==NULL)     {printf("Cant' Open Source");return;}
if((d=fopen(strcat(file,ext),"wb"))==NULL){printf("Cant' Open Detina");return;}
if(findfirst(ParamStr[1],&blk,0)!=0) {printf("FindError");return;}
if(blk.ff_fsize>20000) {printf("File to Long");return;}
fprintf(d,"unsigned char b01[%d]={",blk.ff_fsize); //Info Über Dateien
for(lv=0;lv<blk.ff_fsize-1;lv++){c=fgetc(s);
 if(lv%8==0) fprintf(d,"\r\n");
 fprintf(d,"0x%.2X,",c);};
 c=fgetc(s);                     //Letztes Zeichen
fprintf(d,"0x%.2X};\r\n",c);     //
fclose(s);fclose(d);}