diff options
-rw-r--r-- | ch7/7-05_postfix-calc-scanf.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/ch7/7-05_postfix-calc-scanf.c b/ch7/7-05_postfix-calc-scanf.c index 161f5f0..fa20f27 100644 --- a/ch7/7-05_postfix-calc-scanf.c +++ b/ch7/7-05_postfix-calc-scanf.c @@ -64,29 +64,29 @@ int main() { push(a); } else if (sscanf(s, "%s", buf)) { for (c = buf; *c; c++) { - switch (*c) { - case '+': - push(pop() + pop()); - break; - case '*': - push(pop() * pop()); - break; - case '-': - op2 = pop(); - push(pop() - op2); - break; - case '/': - op2 = pop(); - if (op2 != 0.0) { - push(pop() / op2); - } else { - printf("Error: Cannot divide by zero.\n"); - } - break; - default: - printf("Error: Unknown command %s\n", s); - break; - } + switch (*c) { + case '+': + push(pop() + pop()); + break; + case '*': + push(pop() * pop()); + break; + case '-': + op2 = pop(); + push(pop() - op2); + break; + case '/': + op2 = pop(); + if (op2 != 0.0) { + push(pop() / op2); + } else { + printf("Error: Cannot divide by zero.\n"); + } + break; + default: + printf("Error: Unknown command %s\n", s); + break; + } } if (ltr == '\n') { printf("%.8f\n", pop()); |