Commit 2cab4c3e authored by dragontamer lance's avatar dragontamer lance

Tentatively claiming completion of general purpose encoder/decoder

parent 173ef256
#include <stdio.h>
#include <stdlib.h>
void strdec(int achar, FILE *infile)
{
putchar('S');
achar=0;
while(achar != '"' && achar != EOF)
{
achar=fgetc(infile);
if(achar != 0)
{
if(achar == '"')
{
/* end string */
printf("0");
}
else
{
printf("%d,",achar);
}
}
else /* ; or eof */
{
/* if(achar==';')
{
putchar('0');
}*/
// printf("%d",achar);
}
}
}
int main(int argc, char **argv)
{
if(argc == 2)
......@@ -31,47 +62,24 @@ int main(int argc, char **argv)
printf("%c",(char)achar);
}
}
/* translate back into stupid integer format */
while(achar != EOF)
{
achar = fgetc(infile);
achar=fgetc(infile);
if(achar != EOF)
{
/*
this isn't actually right. It assumes that each line only contains
one string, when in fact strings are simply signified as starting
with 'S' and ending with a null (,0) and a semicolon.
*/
printf("S");
}
else
{
return 0;
}
while(achar != ';' && achar != EOF) {
if(achar != 0)
if(achar == '"')
{
printf("%d,",achar);
strdec(achar, infile);
}
else /* ; or eof */
else
{
if(achar==';')
{
putchar('0');
}
printf("%d",achar);
printf("%c",achar);
}
achar = fgetc(infile);
}
printf(";");
achar=fgetc(infile);
while(achar != '\n' && achar != EOF)
{
printf("%c",achar);
achar = fgetc(infile);
}
printf("\n");
fgetc(infile);
}
}
else
......
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