From b8449c966f337cad327870c8a377ad76f682f28b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 19 Nov 2026 15:16:01 +0100 Subject: [PATCH] error fixing stack.h, stack.c --- Startcode/stack.c | 12 ++++++------ Startcode/stack.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Startcode/stack.c b/Startcode/stack.c index b0c3bcc..5bbd4fb 100644 --- a/Startcode/stack.c +++ b/Startcode/stack.c @@ -18,12 +18,12 @@ StackNode *push(StackNode *stack, void *data) if(stack->prev != NULL){ stack = stack->prev; } - } while(stack->prev != NULL) + } while(stack->prev != NULL); stack->prev = malloc(sizeof(StackNode)); - tempnext = *stack; + tempnext = &stack; stack = stack->prev; - stack->value = &data; + stack->value = data; stack->prev = NULL; stack->next = tempnext; @@ -46,7 +46,7 @@ StackNode *pop(StackNode *stack) } else { stack = stack->prev; } - } while(stack->prev != NULL) + } while(stack->prev != NULL); return &stack; } @@ -61,7 +61,7 @@ void *top(StackNode *stack) if(stack->prev != NULL){ stack = stack->prev; } - } while(stack->prev != NULL) + } while(stack->prev != NULL); return stack->value; } @@ -79,6 +79,6 @@ void clearStack(StackNode *stack) } else { stack = stack->prev; } - } while(stack->next != NULL) + } while(stack->next != NULL); return; } \ No newline at end of file diff --git a/Startcode/stack.h b/Startcode/stack.h index dcb0e1d..915664b 100644 --- a/Startcode/stack.h +++ b/Startcode/stack.h @@ -11,6 +11,8 @@ The latest element is taken from the stack. */ //typedef int Node; +typedef void node; + typedef struct node{ void *value; node *next;