| |
| Posted by Andrew Edwards | PermalinkReply |
|
Andrew Edwards
| 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
|