typedef struct
{
struct table **symbols; // array of the stack
int top; //index of the top element
int size; //maximum size of the stack
}stack;
void *createStack(int size)
{
stack *stck;
stck = (stack *) malloc(sizeof(stack));
stck->symbols = ....
stck->size = size;
stck->top = -1;
printf("stack is created --> size is : %d \n",size);
}
Here I need to allocate my stack’s symbol array which is “…” but I couldn’t figure out it’s syntax, pls help : )
But that’s if you want to pre-allocate all the space at once. If you want to allocate more as you go, you could start with something smaller than
sizeand allocate more in your push() function when you run out of space.