title: implementing stack with linked list in C
body: <p>I'm having trouble implementing a Stack using a linked list with struct. The program compiles fine but when I run it, it prints the first element but then reads the next node as a NULL. I think it might be an error with my passing of the stack to the push method but I am not sure and I have not been successful in fixing it so I'm asking for your help:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct stackNode{
      char data;
      struct stackNode *nextPtr;
  };
  typedef struct stackNode StackNode;
  typedef StackNode *StackNodePtr;
  
  void convertToPostfix(char infix[], char postfix[]);
  int isOperator(char c);
  int precedence(char operator1, char operator2);
  void push(StackNodePtr *topPtr, char value);
  char pop(StackNodePtr *topPtr);
  char stackTop(StackNodePtr topPtr);
  int isEmpty(StackNodePtr topPtr);
  void printStack(StackNodePtr topPtr);
  
  int main(){
      convertToPostfix(NULL, NULL);
      return 0;
  }
  
  void convertToPostfix(char infix[], char postfix[]){
      StackNode stack = {'(', NULL};
      StackNodePtr stackPtr = &amp;stack;
      push(stackPtr, 'a');
  
      //printf("%s\n", stackPtr-&gt;data);
      printStack(&amp;stack);
  }
  
  void push(StackNodePtr *topPtr, char value){
          StackNode *node;
          node=(StackNodePtr)malloc(sizeof(StackNodePtr));
  
          node-&gt;data=value;
          node-&gt;nextPtr=*topPtr;
          *topPtr=node;
  }
  
  void printStack(StackNodePtr topPtr){
      if(topPtr == NULL){
          printf("%s\n", "NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
          return;
      }
  
      printf("%c\n", topPtr-&gt;data);
      printStack(topPtr-&gt;nextPtr);
  }
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks</p>