I've encountered strange behaviour when using sscanf. Depending on order of a and b in structure one of them is getting 0.
typedef struct MyStructure{
uint8_t a;
uint8_t b;
}MyStructure;
and here is code which gets me confused:
if (2 == sscanf(rawCommand,"%*s %*s %"SCNu8" %"SCNu8"", &a, &b)){
... some code
}
When I change order of variables in structure body to:
typedef struct MyStructure{
uint8_t b;
uint8_t a;
}MyStructure;
sscanf returns 2 but a is 0;
I've tested it on 32bit GCC on linux and above code works in both ways. But when compiling with 64bit GCC on windows 7 it behaves like I mentioned. On boths systems I'm using GCC 4.8.1.