adding element to the end of sequence in C struct
问题 #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;