Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:22:33+00:00 2026-05-30T17:22:33+00:00

I have an if else statement but it seems to be executing the code

  • 0

I have an if else statement but it seems to be executing the code under the if and it should execute the code under the else but i cannot see the reason why my code is below.

If you look at the last if statement where it checks to see if those characters are shown if you notice from 0 – 3 D,W,O,P are not in cells 0 – 3 but it still executes the print statement there can someone tell me why?

will be happy for any help

        order.push_back("V"); //V
            order.push_back("I");//F
            order.push_back("F");//I
            order.push_back("N");//O
            order.push_back("D");//O
            order.push_back("W");//O
            order.push_back("O");//O
            order.push_back("P");//O
            order.push_back("Y");//O
            order.push_back("C");//O
            order.push_back("L");//O
            order.push_back("E");//O
            order.push_back("R");//O
            order.push_back("X");//O

                if(order.front() == "V")
                {
                     it = find(order.begin(), order.end(), "I");
                     ++it;
                     std::string o = *it;
                     DCS_LOG_DEBUG("NEXT 0 " << o);
                     DCS_LOG_DEBUG("NEXT " << *it);


                     int i = find(order.begin(), order.end(), "N") - order.begin();
                     int pos = i;

                     DCS_LOG_DEBUG("POS " << pos);

                     for(int i1 = 0; i1 < pos; i1++)
                     {
                         DCS_LOG_DEBUG("IN LINE " << order[i1]);

                         if(order[i1] == "D" || "W" || "O" || "P")
                         {
                             DCS_LOG_DEBUG("It matches one of the above incorrect");
                         }
                         else
                         {
                             for(pos; pos < order.size(); pos++)
                             {

                                 DCS_LOG_DEBUG("FOUND AFTER POS INDEX " << order[pos]);
                                 }
                       }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:22:34+00:00Added an answer on May 30, 2026 at 5:22 pm
    if(order[i1] == "D" || "W" || "O" || "P")
    

    checks order[i1] == "D" for truth. If that is not true it then checks "W" for truth. That is always true and so the compiler can probably work out that this test always evaluates to true.

    What you really mean is

    if(order[i1] == "D" || order[i1] == "W" || order[i1] == "O" || order[i1] == "P")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code and it seems to me that it should always
I have an if/else statement in the controller and 2 different types of views
ill have an if statement if (int1 < int2) {} else {} I want
Is it possible to have a SELECT statement in mySQL with an IF/ELSE clause
I'm getting Reaching end of non-void function warning, but don't have anything else to
up to now I have been using a if and else statement to define
then, elif, else statement that I have programmed in a bash script. I know
I am writing some code in VB.NET that uses a switch statement but in
I have written the code below to generate a matrix containing what is, to
I have the following code: echo <script type='text/javascript'> if(window.location.href.toLowerCase().indexOf('test') != -1) { } else

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.