I'm trying to push a pointer of my element into the stack so it would return a pointer instead of the element.
Based on my limited understanding it's returning the element but not the pointer.
typedef struct Stack
{
int capacity;
int size;
TLDNode* elements;
}Stack;
void push(Stack *S,TLDNode *element)
{
S->elements = element;
S->size = S->size + 1;
return;
}
Stack *S;
S = (Stack *)malloc(sizeof(Stack));
S->elements = ( TLDNode *)malloc(sizeof( TLDNode)*100);
S->size = 0;
S->capacity = 100;
PUSHTOSTACK(tld->head, S);
void PUSHTOSTACK(TLDNode *root,Stack *S) {
PUSHTOSTACK(S,root);
}
S->size = S->size + 1;can be simplified toS->size += 1;or evenS->size++;