cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert uint8_t to string

hande
Associate II

how to convert uint8_t to string and show in SSD1306_Puts

i try like this.

uint8_t check;

SSD1306_Puts("choose dreep"+String(uint8_t), &Font_7x10, 1);

4 REPLIES 4
AvaTar
Lead

Are you talking about a C++ project ?

The library containing SSD1306_Puts() is most probably not. I guess it wants a pointer as first parameter (uint8_t *).

> how to convert uint8_t to string

You cannot. "Strings" are arrays in plain C.

hande
Associate II

is it written like this. please help

  

SSD1306_Puts((uint8_t*)check, &Font_11x18, 0);

AvaTar
Lead

As said, I don't know this library, or said function. But supposedly, something like this should do:

uint8_t string[STRSIZE];

...

sprintf (string, "...

SSD1306_Puts (string, &Font_11x18, 0);

You would need some type casts (char to uint8_t), and the sprintf() formattings, of course. And it's your responsibility to check for the array (string) sizes.

You could use own code to create/combine strings, to avoid the costly clib functions (printf(), sprintf(), etc.).

hande
Associate II

Okay thank you very much AvaTar.