I have a CString that I want to split into small lines. This is a line consisting of a constant 2-byte header and a two-byte footer, but there is no distinguishable template in the rest of the line. I need to break them down based on sizes: so the first two bytes become the header, then I need to extract the next 2, then 3 and so on. (these numbers do not matter)
Example:
CString test = "1010eefabbccde1f1f"
I need
CString header = "1010";
CString test1 = "eefa";
CString test2 = "bbccde";
CString footer = "1f1f";
I read about sscanfused for this purpose, but I managed to use it only for split lines in int.
Example:
CString test = '101022223333331010';
int a,b,c,d;
sscanf(test,"%02d%02d%03d%02d",&a,&b,&c,&d);
This works for strings containing only numbers. But when I do the same for strings, changing %dto %s, exceptions get.
Is there a better way to do this?