From 6324b6bf2f16144a087221118eefb0cbd19e730b Mon Sep 17 00:00:00 2001 From: Ivan Leichenko Date: Mon, 14 Oct 2024 15:47:58 +0200 Subject: [PATCH] upd again cv3 --- cv3/program.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cv3/program.c b/cv3/program.c index 37fcc86..a8a5363 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -29,6 +29,10 @@ float getnpop(struct stack* stack) int calculate(struct stack* stack, char operator) { + if(stack->size < 2) + { + return 2; + } float num1 = getnpop(stack); float num2 = getnpop(stack); float res = 0; @@ -108,6 +112,11 @@ int main(int argc, char const *argv[]) printf("division by zero\n"); return 0; } + else if(calculate(&calc_stack, buf[0]) == 2) + { + printf("not enough operands\n"); + return 0; + } } for (int i = 0; i < calc_stack.size; i++) {