Commit 5f820905 authored by dragontamer lance's avatar dragontamer lance

Worked around Windows' stupid fopen() behavior.

parent 3a0b9ad0
horrible C programs that convert Flexible Survival's newer 'export progress'
data format to human readable text and back again, since they changed from the
previous 'saveword' format recently.
previous 'saveword' format recently. Uses only `putchar()`, `getchar()`, and
one `ungetc()` for I/O, and uses no `malloc()`'s.
I wrote this program extremely quickly and somewhat badly, so that's not really
too surprising. As far as C goes, this is most definitely not too good for
......
......@@ -3,31 +3,23 @@
void strdec(int achar, FILE *infile)
{
putchar('S');
putchar('S'); /* indicates beginning of a string */
achar=0;
while(achar != '"' && achar != EOF)
{
achar=fgetc(infile);
if(achar != 0)
if(achar != 0) /* null terminators in text form, lol */
{
if(achar == '"')
{
/* end string */
printf("0");
printf("0"); /* tack on the terminator*/
}
else
{
printf("%d,",achar);
}
}
else /* ; or eof */
{
/* if(achar==';')
{
putchar('0');
}*/
// printf("%d",achar);
}
}
}
......@@ -36,7 +28,7 @@ int main(int argc, char **argv)
{
if(argc == 2)
{
FILE *infile=fopen(argv[1], "r");
FILE *infile=fopen(argv[1], "rb");
if(infile == NULL)
{
printf("Error: failed to open file.\n");
......
......@@ -5,7 +5,7 @@ int main(int argc, char **argv)
{
if(argc == 2)
{
FILE *infile=fopen(argv[1], "r");
FILE *infile=fopen(argv[1], "rb");
if(infile == NULL)
{
printf("Error: Failed to open file.\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment