aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzlg <zlg@zlg.space>2016-10-12 06:54:44 -0700
committerzlg <zlg@zlg.space>2016-10-12 06:54:44 -0700
commitce7f0379df5dbfca9b86492ea5d2993196a1cc52 (patch)
tree5fb69e2a45901de59873970895ddbafba479c2a4
parentSolve Exercise 7-5: RPN calculator with scanf() (diff)
downloadknr-ce7f0379df5dbfca9b86492ea5d2993196a1cc52.tar.gz
knr-ce7f0379df5dbfca9b86492ea5d2993196a1cc52.tar.bz2
knr-ce7f0379df5dbfca9b86492ea5d2993196a1cc52.tar.xz
knr-ce7f0379df5dbfca9b86492ea5d2993196a1cc52.zip
Actually run astyle on the file...
-rw-r--r--ch7/7-05_postfix-calc-scanf.c46
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());