I program on the AVR XMEGA microcontroller using AtmelStudio.
I am having trouble converting a string to float. The string is called token2and matters"8.604165"
token2
"8.604165"
I have already tried several functions:
float lon = atof(token2); printf("lon=%f", lon);
lon=?
float lon = strtod(token2, NULL); printf("lon=%f", lon);
float lon = strtof(token2, NULL); printf("lon=%f", lon);
undefined reference to strtof
<stdlib.h>
Am I doing something wrong?
So, this is something special for microcontrollers.
Just what I said @Sneftel, I just needed to add the library libprintf_flt.aand libm.ain AtmelStudio.
libprintf_flt.a
libm.a
AVR-libc , . , atof, , , . printf , .
atof
printf
AVR-libc , printf. printf , , . , printf ( , ), printf_min, . , , printf_flt.
printf_min
printf_flt
. , -Wl,-u,vfprintf -lprintf_flt -lm .
-Wl,-u,vfprintf -lprintf_flt -lm
Source: https://habr.com/ru/post/1652474/More articles:нотариус докеров: tls: негабаритная запись получена с длиной 20527 - dockerКак написать правило шаблона для разделения, где находятся объект и исходные файлы? - c++Как проверить реакционно-реагирующие компоненты с ферментом? - reactjsHow to upload files to a path other than lib (Elixir) - elixirHow to present a ViewController using UIImagePickerController - optimizationRedux UI state in objects - reactjsDoes [NotMapped] add a whole class display exception to a partial class? - c #How to write text in one database column for each new user when registering in Laravel 5.2? - phpPassing a lambda that returns polyorphic unique_ptr as a function pointer - c ++Использование прозрачной версии Accent Color - androidAll Articles