Results 1 to 4 of 4

Thread: A SIMPLE question

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    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(hwndbuffer"D",MB_OK);
                    
    CheckDlgButton(hwndIDC_LOADATSTARTUPBST_CHECKED);
                }
                else
                {
                    
    CheckDlgButton(hwndIDC_LOADATSTARTUPBST_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?
    Baaaaaaaaah

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Thanks Parskie It is working now...just curious that why the first method did not work?
    Baaaaaaaaah

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width