sscanf doesn´t work right

Thread Starter

kubeek

Joined Sep 20, 2005
5,795
Hi,

I´m trying to match some commands with sscanf.
Rich (BB code):
char i, c,d,e;
    i=sscanf("SET S 6 H ", "SET S%d H %d",&c,&d);
     printf("scan %d: %d %d",i,c,d);
responds "scan 1: 6 0"
so it doesn´t parse the second number. however when I add the expected number to the input, the first number becomes zero.
Any clues?


Rich (BB code):
char i, c,d,e;
    i=sscanf("SET S 6 H 4", "SET S%d H %d",&c,&d);
     printf("scan %d: %d %d",i,c,d);
responds "scan 2: 0 4"
 

Thread Starter

kubeek

Joined Sep 20, 2005
5,795
solved :)

When compiler issues warnings, correct them. It said that &c should be int but is char which I ignored, so the high byte of that int overwrote the other variable.
 
Top