this should be your declaration
Code:
/*FILE store.h*/
#ifndef _STORE_H_INC_
#define _STORE_H_INC_
typedef struct _store{
char * recordtype;
int itemqty;
float itemprice;
int markup;
struct st_n { /*linked list node*/
_store *pnext,*pprev;
}link;
}store;
struct st_list{
struct st_h { /*linked list header...*/
_store *pfirst, *plast;
}head;
int count;
};
#endif
As for the Linked list implementation
just look of the macroses in the attachment
i made...
Usage of some of the macroses:
Code:
/*LST_INIT: init list*/
st_list some_list;
LST_INIT(&some_list.head);
Code:
/*LST_INS_TAIL: inserts a node at the tail*/
st_list some_list;
store some_store;
LST_INS_TAIL(&some_list.head, &some_node,st_n);
Code:
/*LST_INS_HEAD: inserts a node at the head*/
st_list some_list;
store some_store;
LST_INS_HEAD(&some_list.head, &some_node,st_n);
Code:
/*LST_REMOVE(head, elm, field): removes a node from a list
WARNING!! this does not free the memory!
You should save the pointer
and delete it after that*/
st_list some_list;
store *lp_some_store;/*some valid allocated pointer (malloc-ed)*/
store *save = lp_some_store; /*save the pointer*/
/*remove from list*/
LST_REMOVE(&some_list.head, lp_some_store, st_n)
/*free the mem*/
free(save);
LST_REMOVE(head, elm, field)