From a04005486d2422054fcd98a2c2e891b54ac79bba Mon Sep 17 00:00:00 2001 From: hofmannsv99200 Date: Fri, 12 Dec 2025 09:06:39 +0100 Subject: [PATCH] =?UTF-8?q?Kommentare=20=20in=20stack=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stack.c | 7 +++++-- stack.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/stack.c b/stack.c index 0cef506..49897e2 100644 --- a/stack.c +++ b/stack.c @@ -9,8 +9,9 @@ // Pushes data as pointer onto the stack. -// *ist das ganze konstrukt -// *data soll gepusht werden +// *stack zeiger auf das ganze konstrukt +// *data soll oben drauf gepusht werden; daten die davor drin waren werden runtergeschoben +// stack wird zurückgegeben StackNode *push(StackNode *stack, void *data) { if(data != NULL) @@ -37,6 +38,7 @@ StackNode *push(StackNode *stack, void *data) // Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be // freed by caller.) +// data wird entfernt-> next wird der neue stack StackNode *pop(StackNode *stack) { if(stack != NULL) @@ -49,6 +51,7 @@ StackNode *pop(StackNode *stack) } // Returns the data of the top element. +// gibt das oberste Element aus (data) void *top(StackNode *stack) { if(stack == 0) diff --git a/stack.h b/stack.h index 43e236c..8eeb886 100644 --- a/stack.h +++ b/stack.h @@ -9,8 +9,8 @@ The latest element is taken from the stack. */ //TODO: passenden Datentyp als struct anlegen typedef struct Stack{ - void *data; - struct Stack *next; + void *data; //zeiger auf variable + struct Stack *next; // zeiger auf ein weiteres stack (data und next) } StackNode; // Pushes data as pointer onto the stack.