This commit is contained in:
Valér Jakubčo 2021-10-22 00:12:54 +02:00
parent b21c094531
commit 6ebca183a1

View File

@ -1,3 +1,4 @@
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -14,7 +15,6 @@ struct stack{
void print_stack(struct stack* stack); void print_stack(struct stack* stack);
void push_stack(struct stack* stack, float value); void push_stack(struct stack* stack, float value);
float pop_stack(struct stack* stack); float pop_stack(struct stack* stack);
int count_stack(struct stack* stack);
@ -74,19 +74,23 @@ int main(){
print_stack(&myStack); print_stack(&myStack);
printf("\n"); printf("\n");
} }
} else if(isdigit(char_value[0]) != 0 ){
float_value = strtof(char_value, NULL);
//printf("float value: %f\n",float_value);
if(float_value == 0){
puts("bad input");
break;
} else {
push_stack(&myStack,float_value);
print_stack(&myStack);
printf("\n");
continue;
}
} else { } else {
float_value = strtof(char_value, NULL); puts("bad input");
if(float_value == 0){ break;
puts("bad input"); }
break; } else {
} else {
push_stack(&myStack,float_value);
print_stack(&myStack);
printf("\n");
continue;
}
}
}else {
//push_stack(&myStack, float_value); //push_stack(&myStack, float_value);
//print_stack(&myStack); //print_stack(&myStack);
//printf("\n"); //printf("\n");