spining123
Technical User
Question: How do you parse this string separating $a, $b, $c, and $d, into separate new fields. I know I will need to declare the field’s names; but not should of using the strstr or strch to separate the fields.
Example of the table:
typedef struct
{
char fieldA[50];
char fieldB[200];
} hrgtable;
tableA tabA[] = {
"1 $aSome data in field A","111$bPart1 of fieldB$cPart2 of fieldB$dPart3 of fieldB”,
"2 $aSome data in field A","222$bPart1 of fieldB$cPart2 of fieldB$dPart3 of fieldB”,
"3 $aSome data in field A","333$bPart1 of fieldB$cPart2 of fieldB$dPart3 of fieldB”,
};
Example of the code to parse string:
if (( m = strstr(tabA.fieldB,"$c")) !=NULL)
{
len = m - (tabA.fieldB);
printf("Testing... what's in m ^^^%s^^^\n",m);
This is what’s m… $cPart2 of fieldB$dPart3 of fieldB
I just want the string data starting at $c and ending at $d.
I did the following to copy the data starting at $d into n.
n = strchr(m,'$');
printf("Testing... what's in n ^^^%s^^^\n",n);
This is what’s n… $dPart3 of fieldB
I’m trying to get the data starting at $c and ending at $d strcat to textout.
strcat(textout,n - m);
};
I get the error message:
1506-280 (W) Function argument assignment between type
s "const unsigned char*" and "long" is not allowed.
Thank you in advance for your help.