-
A SIMPLE question
Hi, I have a variable which has value of "Yes" or "No". At this time, I have set the value to "No" but I have a problem. First look at this if statement:
PHP Code:
if(buffer && "Yes")
{
MessageBox(hwnd, buffer, "D",MB_OK);
CheckDlgButton(hwnd, IDC_LOADATSTARTUP, BST_CHECKED);
}
else
{
CheckDlgButton(hwnd, IDC_LOADATSTARTUP, BST_UNCHECKED);
}
If the value in "Yes", it puts a checkmark, else it does not. But it does put a checkmark and messagebox also says that the value is "No". What do I do to make it work the correct way?
-
Code:
if(strcmp(buffer, "Yes") == 0) { /* ... */ } else { /* ... */ }
:)
-
Thanks Parskie:) It is working now...just curious that why the first method did not work?
-
Code:
if(buffer && "Yes")
This does a logical AND with buffer and an arbitrary pointer that represents the location of the constant character string "Yes" (stored somewhere in the EXE file - the pointer will be mapped at load time). So, as long as buffer is not NULL, then it will always act as true :)