1 #if !defined( CSTACK_H )
5 * A implementation of a char stack in heap memory.
7 * struct: cstack_t which defines char stack type in heap memory
9 * function: cstack_init to intialize struct of type cstack_t
10 * function: cstack_t->push to add one char on top if the stack
11 * function: cstack_t->pop to remove the top char from the stack
12 * function: cstack_t->top to test if the top char is a given char
13 * function: cstack_t->empty to test if the stack is empty
14 * function: cstack_t->delete to free the allocated memory
17 * cstack_t *p = cstack_init();
19 * printf("%c\n", (p->pop)(p));
24 typedef struct _cstack_t {
29 void (*push)(struct _cstack_t *self, char c);
30 char (*pop)(struct _cstack_t *self);
31 int (*top)(struct _cstack_t *self, char c);
32 int (*empty)(struct _cstack_t *self);
33 void (*delete)(struct _cstack_t *self);
36 cstack_t *cstack_init();
37 void cstack_push(cstack_t *self, char c);
38 char cstack_pop(cstack_t *self);
39 int cstack_top(cstack_t *self, char c);
40 int cstack_empty(cstack_t *self);
41 void cstack_delete(cstack_t *self);
43 #endif // !defined( CSTACK_H )