postfix calculator using stacks
Posted on 1998-02-05
I need to write a program that is a post fix calculator.
The program must be able to deal with the user either entering a floating point number or a '+' ,a '-',a '*' ,or a '/'. If one or more numbers are entered and the user hits return before entering the operation symbols '*\+-', then the list of numbers must be printed out from the stack. If a user enters an operation symbol (=-*/) then the operation must be performed on the two numbers previous to it and the result must be placed on the stack which is then printed out. If the user hits q then the current stck must be printed out. If the user enters an operation on the stack and only one number has been entered previously, then an error message must be printed. How can i do this ? The data is scanned in as a string..but then must be tested against atof...i have read that atofs behavior is undefined if it does not come against a number when called. I don't know how to implement this all into a loop ? suggestions! please....