I'm trying to build a project for my SAM3S microcontroller. I am using the atof function to convert a string of characters passed to the micro through UART into a float, but when i want to see the result of the conversion (through printf) the value printed is only "f".
#include <stdlib.h>
#include <stdio.h>
int main(){
char str[7];
float number;
//receives the string of characters through UART and saves it in str
number=atof(str);
printf("received: %s converted in: %lf",str,number);
}
And the result of the operation is: "received 10.000 converted in: f". I also tried with strtod(str,NULL);
and hopelessly with even sscanf, but the value remains the same. Each calculus made with 'number'keeps returning 'f' when printed.
I think the error is in the conversion. Do you have suggestions?
Thank you