From 49b50ab708de7cf60ea73c5be31ad089dee169b6 Mon Sep 17 00:00:00 2001 From: Basti Date: Tue, 2 Dec 2025 15:12:01 +0100 Subject: [PATCH] Structur angelegt --- stack.c | 5 ++++- stack.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/stack.c b/stack.c index e3a90d4..c78727b 100644 --- a/stack.c +++ b/stack.c @@ -10,7 +10,10 @@ // Pushes data as pointer onto the stack. StackNode *push(StackNode *stack, void *data) { - + StackNode *top = malloc(sizeof(StackNode)); + top->next= stack; + top->data= data; + return top; } // Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be diff --git a/stack.h b/stack.h index f7d542d..a9d2e58 100644 --- a/stack.h +++ b/stack.h @@ -8,6 +8,11 @@ The latest element is taken from the stack. */ #include //TODO: passenden Datentyp als struct anlegen +typedef struct StackNode +{ + void *data; + struct StackNode *next; +}StackNode; // Pushes data as pointer onto the stack. StackNode *push(StackNode *stack, void *data);