AnsweredAssumed Answered

Floating point support in sscanf()

Question asked by Salavat Magazov on May 25, 2017
Latest reply on May 25, 2017 by howard n2wx

I am having trouble parsing floating point numbers with sscanf(). Code snippet:

int testInt1, testInt2, testInt3;
float testFloat1, testFloat2;
testInt3 = sscanf("1, 2, 2.71, 3.14", "%d, %d, %f, %f", &testInt1, &testInt2, &testFloat1, &testFloat2);

After sscanf is executed: testInt1 = 1, testInt2 = 2, and testInt3 = 2. testFloat1 and testFloat2 are unaffected. After digging on the internet I found that gcc linker might use _write() and _read() in place of all scanf() and printf() incarnations and those functions are not meant to support floating point operation. Other sources state that linker will by default use integer only implementations of printf() and scanf() to save codespace. 

I would like to actually understand the problem rather than solve it by feeding linker different options such as -u _scanf_float

Any pointers to relevant documentation would be much appreciated.

P.S. I am using CubeMX to generate code and Eclipse with GCC (SW4STM32).

Outcomes