Fix bug with substraction

This commit is contained in:
Inex Code 2020-03-07 14:21:02 +03:00
parent bf45a0eec8
commit b7c0451cd2
1 changed files with 3 additions and 2 deletions

View File

@ -97,7 +97,7 @@ void divide(STACK* st) {
int parse(char *s, STACK* stack) {
double operand = 0;
char *endptr;
if (*s == '-' && *(s+1) != '\0') {
if ((*s == '-') && (*(s+1) == '\0')) {
substract(stack);
return 0;
} else if (*s == '+') {
@ -119,7 +119,7 @@ int parse(char *s, STACK* stack) {
int main(int argc, char **argv) {
STACK* operands = init_stack(100);
STACK* operands = init_stack(argc);
int error;
while(*++argv) {
error = parse(*argv, operands);
@ -129,6 +129,7 @@ int main(int argc, char **argv) {
}
}
int i;
printf("Stack status:\n");
for (i = (operands -> cnt); i > 0; i--) printf("%f\n", pop(operands));
return 0;
}