C Stack push function
<p>I try to implement a stack in C but I get a very strange error. For some reason my push function does not work..</p>

<pre><code>typedef struct node
{
    int v;
    struct node* next;
}Node;

void push(Node *stack,int val)
{
    Node *p = (Node *)calloc(1,sizeof(Node));
    p-&gt;v = val;
    Node *aux = stack;
    if(aux == NULL)
    {
        stack = p;
        return;
    }
    while(aux-&gt;next != NULL)
        aux = aux-&gt;next;
    aux-&gt;next = p;
}
</code></pre>

<p>I initialized my stack with NULL</p>

<pre><code>Node *stack = NULL;
</code></pre>

<p>and I call the function something like this</p>

<pre><code>push(stack,value)
</code></pre>

<p>L.E.
I tried to create a pop function with parameter double pointer but the result is the same as for push.</p>

<pre><code>void pop(Node **l)
{
    if((*l) == NULL)
        return;
    else
    {

        Node *aux,*prev;
        prev = *l;
        aux = prev-&gt;next;
        if(aux == NULL)
        {
            free(prev-&gt;v);
            free(prev);
            return;
        }
        while(aux != NULL)
        {
            prev = aux;
            aux = aux-&gt;next;
        }
        prev-&gt;next = NULL;
        free(aux-&gt;v);
        free(aux);
    }
}
</code></pre>