Why does hasParenthesis
always evaluate to true?
bool hasParenthesis = false ;
for(int i = 0; i < 255 && statement[i] != ';'; i++)
{
if(statement[i] == '(' || statement[i] == ')')
{
hasParenthesis = true;
break;
}
}
When the for loop starts, set hasParenthesis
to be false. With what you currently have, once the boolean's true, it'll always be true when the loop re-iterates. So start off the for loop logic with the boolean false.
Here's a simplified skeleton:
bool hasParenthesis;
for(){
hasParenthesis = false;
if(){
hasParenthesis = true;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments