Structur angelegt

This commit is contained in:
Basti 2025-12-02 15:12:01 +01:00
parent c55efdda3c
commit 49b50ab708
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -8,6 +8,11 @@ The latest element is taken from the stack. */
#include <stdlib.h>
//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);