AnsweredAssumed Answered

sscanf function fails CW 5.9 IDE

Question asked by John Borchers on Mar 16, 2011
Latest reply on Mar 22, 2011 by Daniel Lundin

The function  vsscanf(LIBDEF_ConstStringPtr ps, LIBDEF_ConstStringPtr format, va_list args) in the scanf.c library always fails.

 

Input:

int x;

int result;

result=sscanf("123","%d",&x);

 

result always returns 0 and x never has the value 123.

This is because:

 

            if (*s++ == *format++) { /*lint !e931 the expression is safe */

in the function vsscanf line can never be true. The code then jumps to inputFailure

 

Why would the input string be compared against the format string? It doesn't seem to make any sense.


  

Outcomes