c++ - char '9' to int 9
- Andrew Edwards (11/11) Jun 22 2003 I am trying to create a program that evaluates postfix-expressions.
- Gisle Vanem (3/5) Jun 22 2003 You push '9' - '0' = 9 onto the stack.
- Andrew Edwards (3/3) Jun 22 2003 You are a lifesaver...
I am trying to create a program that evaluates postfix-expressions. Currently I read the expression character-by-character from the user and check to see if it is a digit or one of four arithmetic operators: +, -, *, and /. If it is, I concatenate it onto a string. I then index through the string, pushing digits unto a stack. When an operator is encountered, I pop off the top two operands, perform the operation, and push the result back unto the stack. If char '9' is encountered I want to push the integer 9 onto the stack, not 57 (i.e. '9'). How do I accomplish this? Thanks, Andrew
Jun 22 2003
"Andrew Edwards" <edwardsac spamfreeusa.com>:If char '9' is encountered I want to push the integer 9 onto the stack, not 57 (i.e. '9'). How do I accomplish this?You push '9' - '0' = 9 onto the stack. --gv
Jun 22 2003
You are a lifesaver... Thanks.. Andrew
Jun 22 2003