Reviewing my implementation of a stack using linked list
Some minor comments to add to what others have said.


Adding an underscore to the end of struct stack is just noise. It achieves
nothing, so leave it out.
Omit the spaces around -&gt; and add them after keywords (if, while etc)
you are allocating only enough memory to hold a pointer to a stack node
(stack*). Instead you should be allocating a node:

head = malloc(sizeof(stack));


or:

head = malloc(sizeof *head);


Note also that there is no cast (we are writing C, not C++)




The version suggested by @ChrisWue is elegant, but it does need
two structures.  You could achieve the same thing but with only a
single struct (your existing stack) like this:

stack* push(stack *head, int data, int *result)
{
    stack *s = malloc(sizeof *s);
    if (s) {
        s-&gt;data = data;
        s-&gt;next = head;
        *result = 1;
    }
    else *result = 0;
    return s;
}

stack* pop(stack *head, int *data, int *result)
{
    if (!head) {
        *result = 0;
        return head;
    }
    *result = 1;
    stack *next = head-&gt;next;
    *data = head-&gt;data;
    free(head);
    return next;
}


But note that you must then be careful always to assign the return value to
head in the caller:

    int data;
    int ok;
    stack *head = NULL;
    ...
    head = push(head, data, &amp;ok);
    if (ok) {
        ...
    }
    head = pop(head, &amp;data, &amp;ok);
    if (ok) {
        ...
    }