kolibrios/programs/games/donkey/utils/file2c.cpp
Yogev Ezra 0555bd8c9a 'Donkey' game - merge with 0.8 sources from diamond's last nightbuild.
git-svn-id: svn://kolibrios.org@1811 a494cfbc-eb01-0410-851d-a64ba20cac60
2011-01-30 12:47:07 +00:00

39 lines
636 B
C++

#include <stdio.h>
const char hextable[] = "0123456789abcdef";
int main(int argc, char *argv[])
{
FILE *fin;
FILE *fout;
unsigned i;
int num;
if (argc != 3)
{
printf ("file2c v0.2 by O.Bogomaz (albom85@yandex.ru)\nfile2c.exe file.in file.out\n\n");
return -1;
}
fin = fopen (argv[1], "rb");
fout = fopen (argv[2], "wt");
fprintf(fout, "char array[]= {");
for (i = 0;; i++)
{
if ( 0 == i%16)
fprintf(fout, "\n");
num = getc(fin);
if (feof(fin))
break;
fprintf (fout, "0x%c%c,", (int)hextable[(num >> 4)], (int)hextable[(num & 0x0f)]);
}
fprintf(fout, "\n };\n");
return 0;
}