Thread overview
char '9' to int 9
Jun 23, 2003
Andrew Edwards
Jun 23, 2003
Gisle Vanem
Jun 23, 2003
Andrew Edwards
June 23, 2003
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


June 23, 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


June 23, 2003
You are a lifesaver...
Thanks..
Andrew