|
|
*
|
|
we don't want functions outside of the module to be
able to modify Stack, so we will define it in such a
way that it can be stored in variables and passed a
parameter, but it can't be manipulated
this can be done by making Stack a struct pointer, but
not declaring the underlying struct, this can be done in
the following way:
typedef struct stack_struct* Stack;
stack_struct isn't declared in stack.h, it is only
declared in stack.c, so user functions can't manipulate
stacks directly
now we come to stack.c, the file that contains the
actual implementation of the stack module
First, we need to define the stack_struct type, for our
simple implementation we will use an array to store
the stack, since each stack could be a different size
we will need to dynamically allocate the array and
store its size in stack_struct
the declaration of stack_structure is:
|
|