Hello, I am using linux fedora and I am compiling with g++. I am trying to write a postfix calculator program and I am stuck on one part in my code. I enter "2 1 +" and using GDB I figured out that when the '+' is being compared in the if statement, it is not skipping over the if statement, instead the program enters into the if statement and converts the '+' to a 0 and then pushes it into my stack, nums.
You are comparing input[i] to 1 (aka true). Try this cout << ('+'||'-'||'*'||'/'); This shows how that expression is evaluated. Remember that any value that can be converted to an integer can be use in relational operators. In this case, characters like '+' evaluates to true.