|
-
Sep 3rd, 2001, 05:30 PM
#1
Thread Starter
PowerPoster
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?
-
Sep 3rd, 2001, 05:35 PM
#2
Monday Morning Lunatic
Code:
if(strcmp(buffer, "Yes") == 0) { /* ... */ } else { /* ... */ }
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 3rd, 2001, 05:47 PM
#3
Thread Starter
PowerPoster
Thanks Parskie It is working now...just curious that why the first method did not work?
-
Sep 3rd, 2001, 05:50 PM
#4
Monday Morning Lunatic
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
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|