Hi so I have been trying for so long to figure that out. I created a Stack data struct of linked list with this form:
typedef struct Stack
{
unsigned int data;
Stack* next;
} Stack;
I have been trying to do a push and pop function so many times so many different YouTube videos but nothing seems to work. I tried to create my push function like this:
void push(Stack* s, unsigned int element)
{
Stack* newNode;
newNode = new Stack();
newNode->data = element;
newNode->next = s;
if (s == NULL)
{
s = newNode;
}
else
{
newNode->next = s;
s = newNode;
}
}
but whenever I'm trying to use it im getting s->data = a lot of random numbers like this: 3452816845 Thank you so much of you paying attention I would really be grateful if you can help me fix it. Thanks!