Hi basically the code gets the status of a gtk checkbox (unimportant) then writes "active" or "not active" to a char buffer, i then want to compare this buffer to the value "active" to run an if statement but it never is satisfied and i dont know why - here is my code.
1 2 3 4 5 6 7 8 9 10 11
char redblackstatus[50];
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(redblackcheck));
sprintf(redblackstatus,"%s", active?"active":"not active");
if(redblackstatus == "active"){
/* this never runs even if it is active */
}
i have also tried
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
char redblackstatus[50];
char activestore[50];
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(redblackcheck));
sprintf(redblackstatus,"%s", active?"active":"not active");
sprintf(activestore,"%s", active?"active":"pass");
if(redblackstatus == "active"){
/* this once again isn't satisfied when the button is active */
}
im really stuck with this and my project has come to a stand still with this issue - thanks for your time
You have to use a function from the c run time library. You cannot use operator == to compare a char* to a string. You need to use strcmp. Either that or make redBlackStatus a std::string. std::string supports operator==.