Please recommendation for most simple conversion from integer where integers can be only 0 and 1 to char*, in C language.
I have function which returns 0 or 1 as integer.
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mytogglebutton));
In other module it is function and in third declaration.
int set_locals(char* s_setting, char* s_value);
I try with:
set_locals("my_prop", (char*)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mytogglebutton)));
But this won’t work.
I know how to use sprintf, but when here is only 0 and 1 maybe someone know shorter way?
The shortest way for this would be using the ternary conditional operator:
However this is a
const char*, but as you presented the problem, I don’t think it will be an issue.