This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

sscanf in code composer studio returining 0 instead of 1



#include<stdio.h>
#include<string.h>

int main()
{
  int tmpResult = 5;
  const char    *parameter = "65540 vin";
  char buff[10] = {0};
  tmpResult = sscanf( parameter, "%ld",(unsigned long *)buff );
}
 
I expected the above code to return 1 but its returning 0. I am compiling code for msp430 micro controller using code composer studio idev 5.5.0.00077. msp430 is 16 bit micro controller.

Note: It is returning 1 in Precision32 IDE on 32bit silab Micro controller but its returning 0 in 16 bit MSP430

If i change the code with below line %d instead of %ld, it is returning 1,

tmpResult = sscanf( parameter, "%d",(unsigned long *)buff );

but the buff is stored with one byte 0x04(65536(= 0 for 16 bit %d) + 4 = 65540).

How to store a 32 bit value to a buffer (eg 65540) using sscanf?

what is the problem with code composer studio.?