Hi, I am having a strange problem with a simple process. Heres the code.

bool areNumbers = true;
bool Anything = true;
int numBytes = 1;
long inCrem = 0;
while(gPlacerID != tgPlacers[inCrem]->GetPlacerTypeID())
{
     inCrem++;
     if(inCrem == tgPlacers.size());
     {
           Anything = false;
           break;
     }
}

This code is part of a larger algorithm but I just cut out the part of focus. Say the while loop has been entered and increm gets incremented from 0 to 1. Say tgPlacers.size() is 5.

Now in the if statement when it says if(inCrem == tgPlacers.size()); (for example, if 1 == 5), it goes through to declaring Anything = false, ect. 1 does not equal 5 and it should not be entering the if.

Anyone know why this could be happening? Let me know if you need more info.

Thanks

Member Avatar for iamthwee

stick a few couts there,

Put inCrem++ after the if clause, and see what happens.

I tried your suggestions but its still going in..

I debugged through it too and put the variables in the watch and saw that when 1 == 5, it totally enters the if.

What you really have is this

if(inCrem == tgPlacers.size())
     {
        /* The ; at the end of your if is a NO-OP */
     }
     {
           Anything = false;
           break;
     }

AH!! Very surprised I didn't see that.:icon_redface:

thanks guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.