I need to convert uint16_t value to a string. I want the string to be a decimal respresentation of the number.
Example: uint16_t i=256 string: 256
I tried with itoa(i,string, 10)
but when i
value increases starts printing negative values.
I send the string via the Serial Port.(UART)
It is there some alternative?
Use sprintf
with %u
format for unsigned int
:
uint16_t i = 33000;
sprintf(str, "%u", i);