I am working on a simulate file. The file has many rows with numbers, letters and characters.
Example:
GR123,7894.5444,A,4687.5643,P
GR456,1234.6556,A,9657.5686,P
GR789,2344.3422,A,9786.8465,P
GR987,6522.6354,A,3245.5754,P
I need to take the values before A and P (for the first row, 7894.5444 and 4687.5643).
How can I parse by position this string into an int? Already tried with:
double exampleA = stoi(row.substr(6,9));
double exampleP = stoi(row.substr(18,9));
But it gives me this error: request for member ‘substr’ in ‘row’, which is of non-class type ‘char*’
Also tried:
char exampleA[9];
char exampleP[9];
memcpy(&exampleA, &row[6],sizeof(exampleA));
memcpy(&exampleP, &row[6],sizeof(exampleP));
In order to convert the values after having separated them from the row but the memcpy buffer always brings the value of exampleP with exampleA like:
A : 7894.5444
P : 4687.5643?7894.5444