I am parsing a string (a char *), and I am using sscanf to parse numbers from a string into double, for example:
while(*s){
if(sscanf(s, " %1[MmLl] %f %f %n ", command, &x, &y, &n) == 3){
//Do some processing
s += n;
}
}
This works for most inputs, except in a few cases. The problem is the variable count n. For some input, the variable n is never updated and continues to hold the counter of the previous iteration. This leads to incorrect bias and spoils parsing. I do not see anything strange in case of input failure.
Note. This problem only occurs in windows, since the same code produces the correct output on Linux.
Has anyone encountered similar problems?