summaryrefslogtreecommitdiffstats
path: root/4
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-18 15:16:31 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-18 15:16:31 +0800
commitd9d53cbdaea6f3e87af19587504be04f66467f8f (patch)
treed1824dcae01d46956df9a80d40b54e3ecb44d226 /4
parentab7dad4795b96c9cb869de58eee30e90857a4f23 (diff)
downloadk&r-exercises-d9d53cbdaea6f3e87af19587504be04f66467f8f.tar.gz
4.10
Diffstat (limited to '4')
-rw-r--r--4/10.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/4/10.c b/4/10.c
index 83a9053..c89bf0b 100644
--- a/4/10.c
+++ b/4/10.c
@@ -50,8 +50,8 @@ int main(int argc, char *argv[]) {
push(op1 + op2);
break;
case '-':
- op1 = pop();
op2 = pop();
+ op1 = pop();
push(op1 - op2);
break;
case '*':
@@ -147,7 +147,7 @@ int getop(char s[]) {
// special characters and operators
if (c == 0 || c == '+' || c == '*' || c == '/' || c == '%' || c == '\n' ||
- (c == '-' && !isdigit(line[idx + 1])) || c == EOF)
+ (c == '-' && !isdigit(line[idx])) || c == EOF)
return c;
i = 0;