Hello All,
I am using a stack to create a sort of calculator.
My input string will be "5 6 add"
I have to push 5, push 6, and when I get read "add" pop 5 and 6 and and push the answer.
The question is after the string is broken up by the whitespaces, how do I compare each individual part to the string "add" so when it is equal to "add" it will pop the 5 and 6 and I can continue on with my next step?
For example:
is "5" equal to "add" - no, push onto stack
is "6" equal to "add" - no, push onto stack
is "add" equal to "add" - yes, pop 6, pop 5 and (continue)
Any assistance will be appreciated.
Thanks,
The question I have is when I push 5 and push 6, when I get to "add" how to I use it ias a comparison