FILE *fpin, *fpout;
char cname[256];
char sizest[256];
- long size;
+ size_t size;
int i;
if (argc<1) {
if (argv[1][i]=='.') argv[1][i]='_';
sprintf(sizest, "%d", (int)size);
- printf ("Input filesize is %d, Output size should be %d\n", size, ((int)size)*4 + strlen("/* DataToC output of file <> */\n\n") + strlen("char datatoc_[]= {\"") + strlen ("\"};\n") + (strlen(argv[1])*3) + strlen(sizest) + strlen("int datatoc__size= ;\n") +(((int)(size/256)+1)*5));
+ printf ("Input filesize is %ld, Output size should be %ld\n", size, ((int)size)*4 + strlen("/* DataToC output of file <> */\n\n") + strlen("char datatoc_[]= {\"") + strlen ("\"};\n") + (strlen(argv[1])*3) + strlen(sizest) + strlen("int datatoc__size= ;\n") +(((int)(size/256)+1)*5));
fpout= fopen(cname, "w");
if (!fpout) {
/* fprintf (fpout, "\\x%02x", getc(fpin)); */
fprintf (fpout, "%3d,", getc(fpin));
}
-
- fprintf (fpout, "\n};\n\n");
+ /* null terminate for the case it is a string */
+ fprintf (fpout, "\n 0};\n\n");
fclose(fpin);
fclose(fpout);