pop-Funktion angepasst, erfolgreich getestet

This commit is contained in:
Rebekka Haemmerl 2025-12-10 09:54:54 +01:00
parent 2dc724e065
commit 1a5b7cb025
2 changed files with 2 additions and 7 deletions

View File

@ -31,16 +31,11 @@ StackNode *push(StackNode *stack, void *data)
// freed by caller.) // freed by caller.)
StackNode *pop(StackNode *stack) StackNode *pop(StackNode *stack)
{ {
if(stack) if(stack == NULL)
{
StackNode *t = stack->next; //Naechstes Element im Stack wird erstes Element
free(stack);
return t;
}
else
{ {
return NULL; return NULL;
} }
return stack->next;
} }
// Returns the data of the top element. // Returns the data of the top element.

BIN
test_stack.exe Normal file

Binary file not shown.