This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 15.2.0 - sprintf with float

Hi,

I am trying to fill a buffer with two float, but apparently the sprintf doesn't support floats.

Is it true?

Thanks

    char buffer[51] = {};
    float v = 123.4;
    float i = 100.2;

    sprintf(buffer, "%.4f-%.4f", v, i);

    NRF_LOG_DEBUG("Len %d", strlen(buffer));
    NRF_LOG_DEBUG("Sending %s", (uint32_t)buffer);

Console output

<debug> app: Len 1
<debug> app: Sending -

Parents Reply Children
No Data
Related