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.

Compiler/TM4C1294NCPDT: sscanf return value not ok

Part Number: TM4C1294NCPDT


Tool/software: TI C/C++ Compiler

According to C++ specification, the value returned by sscanf should match the number of items successfully filled. (link)

I tried the following (compiler TI v5.2.5):

bool ToFloat(char* string, float* data)
{
    int temp = sscanf(string, "%f", data);
    return (1 == temp);
}

int main(void)
{
    char testdata[] = "EPRP";
    float parsed;

    bool res = ToFloat(&testdata[0], &parsed);
...

The sscanf returns in this case 1, and the data is 0.0. I tried other strings, like "XXXX" or "PERP", these return 0 as expected.

I tested it with different compilers:

link1, link2, link3, link4

All of them return 0 as expected, so I guess the TI v5.2.5 compiler (also TI v18.1.1.LTS) has an issue with strings starting with 'E' (probably because of the engineering notation?).

Is there a workaround for this problem, or is there a version of stdio library available which works correctly?

Thank you