forked from freudenreichan/info2Praktikum-DobleSpiel
Compare commits
2 Commits
eab7887e4d
...
ce50ae30fa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce50ae30fa | ||
|
|
49b50ab708 |
5
stack.c
5
stack.c
@ -10,7 +10,10 @@
|
|||||||
// Pushes data as pointer onto the stack.
|
// Pushes data as pointer onto the stack.
|
||||||
StackNode *push(StackNode *stack, void *data)
|
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
|
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
||||||
|
|||||||
5
stack.h
5
stack.h
@ -8,6 +8,11 @@ The latest element is taken from the stack. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
//TODO: passenden Datentyp als struct anlegen
|
//TODO: passenden Datentyp als struct anlegen
|
||||||
|
typedef struct StackNode
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
|
struct StackNode *next;
|
||||||
|
}StackNode;
|
||||||
|
|
||||||
// Pushes data as pointer onto the stack.
|
// Pushes data as pointer onto the stack.
|
||||||
StackNode *push(StackNode *stack, void *data);
|
StackNode *push(StackNode *stack, void *data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user