#include "seq.h"
#include <stdio.h>
#include <stdlib.h>
typedef struct stack_node {
ETYPE data;
struct stack_node *prev, *next;
}NODE;
struct seq_struct {
// "Container" struct
NODE* top, *bottom;
int size;
};
/**
* DESCRIPTION: adds a new element to the "back" of
* the seq
*
* [2 4]
* add_back 7
* [2 4 7]
*
*
*/
void seq_add_back(Seq seq, ETYPE val){
NODE* endq = malloc(sizeof(NODE));
endq->next =NULL;
endq->prev = seq->bottom;
endq->data = val;
seq->bottom->next=endq;
seq->bottom = endq;
seq->size++;
return;
}
I need your help in understanding what is wrong with my code. It doesn't add a new element to the sequence at the end like it should been.
I have another portion of code, for deleting and adding elements to the front of of the sequence and it works fine, also to note print function is fine too. everything beeing initialized to NULL, and zero at the start of the program.