Float in sscanf on Teensy 3.1

Status
Not open for further replies.

Rumman

New member
Hi, I am trying to parse a string with floats in it using sscanf. I know the avr-gcc lib doesn't allow using %f format specifier, but since teensy 3.1 uses an cortex-m4 and hence the arm gcc compiler shouldn't something like this work?
Code:
float num;
sscanf("23.4", "%f", &num);
Running a sketch like this results in 0.00 value for num instead of 23.4

Need help
 
Here's the magic trick you need:

Code:
void setup() {
  // this is the magic trick for printf to support float
  asm(".global _printf_float");
  
  // this is the magic trick for scanf to support float
  asm(".global _scanf_float");
}

void loop() {
  float f;
  sscanf("123.456", "%f", &f);
  Serial.println(f);
  delay(1000);
}
 
Status
Not open for further replies.
Back
Top