This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Convert int to char

Hi there, how do I convert int to string to be printed out? 

void RefreshButtonPress(tWidget *pWidget){
uint32_t count = 0;
//----------------change temperature
CanvasTextSet(&g_sTemperatureBox, count);
WidgetPaint((tWidget *)&g_sTemperatureBox);
//----------------change humidity
CanvasTextSet(&g_sHumidityBox, count);
WidgetPaint((tWidget *)&g_sHumidityBox);
count++;}
else{
count = 0;
//----------------reset temperature
CanvasTextSet(&g_sTemperatureBox, "Default");
WidgetPaint((tWidget *)&g_sTemperatureBox);
CanvasTextSet(&g_sHumidityBox, "Default");
WidgetPaint((tWidget *)&g_sHumidityBox);

}

Above is my code. When I print out 'count', the value seems to be random alphabet? Anyone knows how to convert the int value to string?

  • This is basic C question. If there is no performance penalty then "sprintf" or (even better) "snprintf" can be used. TivaWare has a more optimized version of these standard library functions in "utils/ustdlib" called usprintf and usnprintf, that can also be used.

    Thanks,
    Sai