forked from freudenreichan/info2Praktikum-DobleSpiel
error fixing stack.h, stack.c
This commit is contained in:
1 parent
88d3d67d93
commit
b8449c966f
2 files changed
+8
-6
No files matched your search
+6
-6
@@ -18,12 +18,12 @@ StackNode *push(StackNode *stack, void *data)
|
|||||||
if(stack->prev != NULL){
|
if(stack->prev != NULL){
|
||||||
stack = stack->prev;
|
stack = stack->prev;
|
||||||
}
|
}
|
||||||
} while(stack->prev != NULL)
|
} while(stack->prev != NULL);
|
||||||
|
|
||||||
stack->prev = malloc(sizeof(StackNode));
|
stack->prev = malloc(sizeof(StackNode));
|
||||||
tempnext = *stack;
|
tempnext = &stack;
|
||||||
stack = stack->prev;
|
stack = stack->prev;
|
||||||
stack->value = &data;
|
stack->value = data;
|
||||||
stack->prev = NULL;
|
stack->prev = NULL;
|
||||||
stack->next = tempnext;
|
stack->next = tempnext;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ StackNode *pop(StackNode *stack)
|
|||||||
} else {
|
} else {
|
||||||
stack = stack->prev;
|
stack = stack->prev;
|
||||||
}
|
}
|
||||||
} while(stack->prev != NULL)
|
} while(stack->prev != NULL);
|
||||||
return &stack;
|
return &stack;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ void *top(StackNode *stack)
|
|||||||
if(stack->prev != NULL){
|
if(stack->prev != NULL){
|
||||||
stack = stack->prev;
|
stack = stack->prev;
|
||||||
}
|
}
|
||||||
} while(stack->prev != NULL)
|
} while(stack->prev != NULL);
|
||||||
return stack->value;
|
return stack->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +79,6 @@ void clearStack(StackNode *stack)
|
|||||||
} else {
|
} else {
|
||||||
stack = stack->prev;
|
stack = stack->prev;
|
||||||
}
|
}
|
||||||
} while(stack->next != NULL)
|
} while(stack->next != NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ The latest element is taken from the stack. */
|
|||||||
|
|
||||||
//typedef int Node;
|
//typedef int Node;
|
||||||
|
|
||||||
|
typedef void node;
|
||||||
|
|
||||||
typedef struct node{
|
typedef struct node{
|
||||||
void *value;
|
void *value;
|
||||||
node *next;
|
node *next;
|
||||||
|
|||||||
Reference in new issue
Block a user