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

corrected slide 42,

parent 3be27c71
No related branches found
No related tags found
No related merge requests found
Pipeline #14963 passed
......@@ -439,7 +439,8 @@ char *infix_to_postfix(char* infix) { // init and alloc stack and postfix
for (size_t i = 0; i < strlen(infix); ++i) {
if (is_operand(infix[i])) {
// we just add operands in the new postfix string
} else if (infix[i] == '(') { // we push opening parenthesis into the stack
} else if (infix[i] == '(') {
// we push opening parenthesis into the stack
stack_push(&s, infix[i]);
} else if (infix[i] == ')') {
// we pop everything into the postfix
......@@ -537,8 +538,8 @@ typedef element* stack;
stack stack_create(); // return NULL;
void stack_destroy(stack *s);
void stack_push(stack *s, int val);
int stack_pop(stack *s);
int stack_peek(stack s);
void stack_pop(stack *s, int *val);
void stack_peek(stack s, int *val);
bool stack_is_empty(stack s); // reutrn NULL == stack;
```
......@@ -592,8 +593,8 @@ void stack_push(stack *s, int val) {
. . .
```C
int stack_peek(stack s) {
return s->data;
void stack_peek(stack s, int *val) {
*val = s->data;
}
```
......@@ -618,8 +619,8 @@ int stack_peek(stack s) {
. . .
```C
int stack_pop(stack *s) {
int val = stack_peek(*s);
void stack_pop(stack *s, int *val) {
stack_peek(*s, val);
element *tmp = *s;
*s = (*s)->next;
free(tmp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment