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.