Update cv3/program.c

This commit is contained in:
Marat Izmailov 2024-10-17 11:32:53 +00:00
parent 204652d772
commit 2a8785df19

View File

@ -21,6 +21,8 @@ int main() {
memset(&mystack, 0, sizeof(struct stack)); memset(&mystack, 0, sizeof(struct stack));
char input[50]; char input[50];
int empty_input = 0;
while (1) { while (1) {
if (!fgets(input, sizeof(input), stdin)) { if (!fgets(input, sizeof(input), stdin)) {
@ -30,7 +32,7 @@ int main() {
input[strcspn(input, "\n")] = 0; input[strcspn(input, "\n")] = 0;
if (strlen(input) == 0) { if (strlen(input) == 0) {
printf("no input\n"); empty_input = 1;
break; break;
} }
@ -76,10 +78,16 @@ int main() {
print_stack(&mystack); print_stack(&mystack);
} }
if (empty_input) {
printf("no input\n");
}
return 0; return 0;
} }
void push_stack(struct stack* stack, float value) { void push_stack(struct stack* stack, float value) {
assert(stack->size < STACK_SIZE); assert(stack->size < STACK_SIZE);
stack->values[stack->size] = value; stack->values[stack->size] = value;