Skip to content
Snippets Groups Projects
Verified Commit 5da4b703 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

removed element *

parent 47a7cec8
Branches
No related tags found
No related merge requests found
Pipeline #36565 passed
......@@ -294,7 +294,9 @@ typedef struct _element {
int data;
struct _element *next;
} element;
typedef element* stack;
typedef struct _stack {
element *top;
} stack;
```
## Fonctionnalités?
......@@ -302,12 +304,12 @@ typedef element* stack;
. . .
```C
void stack_create(stack *s); // *s = NULL;
void stack_create(stack *s); // s->top = NULL;
void stack_destroy(stack *s);
void stack_push(stack *s, int val);
void stack_pop(stack *s, int *val);
void stack_peek(stack s, int *val);
bool stack_is_empty(stack s); // return NULL == stack;
bool stack_is_empty(stack s); // return NULL == s.top;
```
# La liste chaînée et pile (3/6)
......@@ -335,7 +337,7 @@ void stack_push(stack *s, int val) {
element *elem = malloc(sizeof(*elem));
elem->data = val;
elem->next = *s;
*s = elem;
s->top = elem;
}
```
......@@ -361,7 +363,7 @@ void stack_push(stack *s, int val) {
```C
void stack_peek(stack s, int *val) {
*val = s->data;
*val = s.top->val;
}
```
......@@ -388,8 +390,8 @@ void stack_peek(stack s, int *val) {
```C
void stack_pop(stack *s, int *val) {
stack_peek(*s, val);
element *tmp = *s;
*s = (*s)->next;
element *tmp = s->top;
s->top = s->top->next;
free(tmp);
}
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment