From bd21b7fecbe2287d904ddc2d66a9059da9837577 Mon Sep 17 00:00:00 2001 From: Ivan Leichenko Date: Mon, 14 Oct 2024 15:56:30 +0200 Subject: [PATCH] aaaaaaaaaaaaaaaaaaaa --- cv3/program.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 5c21ecc..0ff6571 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -3,7 +3,7 @@ #include #include #include -#define STACK_SIZE 50 +#define STACK_SIZE 10 struct stack { @@ -11,11 +11,16 @@ struct stack int size; }; -void add(struct stack* stack, float num) +int add(struct stack* stack, float num) { + if(stack->size == STACK_SIZE) + { + return 1; + } assert(stack->size < STACK_SIZE); stack->values[stack->size] = num; stack->size++; + return 0; } float getnpop(struct stack* stack) @@ -103,7 +108,12 @@ int main(int argc, char const *argv[]) if(!check_op(buf[0])) { num = atof(buf); - add(&calc_stack, num); + int add_code = add(&calc_stack, num); + if(add_code == 1) + { + printf("full stack\n"); + return 0; + } } else {