From 2a8785df195173dcc3b159ae8bfe2e5e5c1c696d Mon Sep 17 00:00:00 2001 From: Marat Izmailov Date: Thu, 17 Oct 2024 11:32:53 +0000 Subject: [PATCH] Update cv3/program.c --- cv3/program.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cv3/program.c b/cv3/program.c index 9bfae3f..ba96e19 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -21,6 +21,8 @@ int main() { memset(&mystack, 0, sizeof(struct stack)); char input[50]; + int empty_input = 0; + while (1) { if (!fgets(input, sizeof(input), stdin)) { @@ -30,7 +32,7 @@ int main() { input[strcspn(input, "\n")] = 0; if (strlen(input) == 0) { - printf("no input\n"); + empty_input = 1; break; } @@ -76,10 +78,16 @@ int main() { print_stack(&mystack); } + + if (empty_input) { + printf("no input\n"); + } + return 0; } + void push_stack(struct stack* stack, float value) { assert(stack->size < STACK_SIZE); stack->values[stack->size] = value;