Skip to main content
hande
Associate II
November 8, 2018
Question

how to convert uint8_t to string

  • November 8, 2018
  • 4 replies
  • 2735 views

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);

    This topic has been closed for replies.

    4 replies

    AvaTar
    Senior III
    November 8, 2018

    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
    handeAuthor
    Associate II
    November 8, 2018

    is it written like this. please help

      

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

    AvaTar
    Senior III
    November 8, 2018

    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
    handeAuthor
    Associate II
    November 8, 2018

    Okay thank you very much AvaTar.