From fa32188a7d132bf4398c31558cba5fa0c3453488 Mon Sep 17 00:00:00 2001 From: JebediahS Date: Fri, 5 Sep 2025 21:20:15 +0200 Subject: [PATCH] Update expr.c Filling the stack should start from element with index 0. --- chapter_5/exercise_5_10/expr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter_5/exercise_5_10/expr.c b/chapter_5/exercise_5_10/expr.c index 0770075..52dc199 100644 --- a/chapter_5/exercise_5_10/expr.c +++ b/chapter_5/exercise_5_10/expr.c @@ -108,7 +108,7 @@ float pop(void) { if (stack_pointer > 0) { - return stack[stack_pointer--]; + return stack[--stack_pointer]; } printf("Error: the stack is empty.\n"); @@ -119,7 +119,7 @@ void push(float element) { if (stack_pointer < STACK_SIZE) { - stack[++stack_pointer] = element; + stack[stack_pointer++] = element; } else {