Skip to content

Commit 8229054

Browse files
authored
Update stack.c
The else part in "if (c == '-')" for some reason caused a calculation like "33 44 +" to evaluate to 7. After removing that else part, the output gives the desired result.
1 parent 933e245 commit 8229054

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

chapter_4/exercise_4_04/stack.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ int getop(char s[])
215215
s[++i] = c = next;
216216
}
217217
}
218-
else
219-
{
220-
c = getch();
221-
}
218+
// else
219+
// {
220+
// c = getch();
221+
// }
222+
// This else block caused '33 44+' to output 7 instead of 77
222223

223224
if (isdigit(c))
224225
{

0 commit comments

Comments
 (0)