From cee902690b6cc32806098c823205d0a2a7ef0747 Mon Sep 17 00:00:00 2001 From: Marat Izmailov Date: Thu, 17 Oct 2024 11:25:44 +0000 Subject: [PATCH] Update cv3/program.c --- cv3/program.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cv3/program.c b/cv3/program.c index 2362ea4..3f668cd 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -30,14 +30,17 @@ int main() { input[strcspn(input, "\n")] = 0; if (strlen(input) == 0) { + printf("no input\n"); break; } if (is_number(input)) { + float value = atof(input); push_stack(&mystack, value); } else if (strlen(input) == 1 && strchr("+-*/", input[0])) { + if (mystack.size < 2) { fprintf(stderr, "Error: Not enough values in stack.\n"); exit(EXIT_FAILURE); @@ -93,8 +96,8 @@ float pop_stack(struct stack* stack) { } void print_stack(struct stack* stack) { + for (int i = 0; i < stack->size; i++) { - printf("%.2f ", stack->values[i]); } printf("\n");