I started testing and I can't get it working
I have made the following function:
Code:
void parse(char *line,char *output)
{
char buf[100],ch;
int i,count=0;
//count | tokens in string
for(i=0;ch!='\0';i++)
{
ch=line[i];
if(ch=='|')
count++;
}
printf("count=%d\n",count);
//parse string into fields
for (i=0;i==count;++i)
{
size_t len = strcspn(line,"|");
sprintf(buf,"%*.*s\n", (int)len, (int)len, line);
printf("%s\n",buf);
line += len + 1;
}
}
the token count works fine. The program prints count = 6 when i use the following as input:
Code:
002^Resultaat op aanmelden|20050915|121533|INT^TEMP^1^S|BOOL^LED^1^A|BOOL^LED^2^A|0x0A
the format is: command^comment|date| time|field|field|field|0x0A
unfortunately it doesnt print the fields
i want the function to output an array of fields, but i havent implemented that yet