title: C stack implementation. Question about dereference and double pointers
body: <p>Good day everyone. I am new to C and stack overflow too so go easy on me please :)
  I have few question about this stack code in C:</p>
  
  <p>1) <code>push(&amp;stackPtr, value);</code> why stackPtr has to have &amp; sign ? and what function will get without it?</p>
  
  <p>2) <code>topPtr = newPtr;</code> why topPtr has to be *topPtr ? And what is going on with the code without it?</p>
  
  <p>3) <code>*topPtr = (*topPtr)-&gt;nextPtr;</code> why *topPtr has to have * ? and what gonna be without * sign ?</p>
  
  <p>Thank for any answers in advance. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  // self-referential structure                     
  struct stackNode {                                   
     int data; // define data as an int             
     struct stackNode *nextPtr; // stackNode pointer
  };
  
  typedef struct stackNode StackNode; // synonym for struct stackNode
  typedef StackNode *StackNodePtr; // synonym for StackNode*
  
  // prototypes
  void push(StackNodePtr *topPtr, int info);
  int pop(StackNodePtr *topPtr);
  void printStack(StackNodePtr currentPtr);
  void instructions(void);
  
  // function main begins program execution
  int main(void)
  { 
     StackNodePtr stackPtr = NULL; // points to stack top
     int value; // int input by user
  
     instructions(); // display the menu
     printf("%s", "? ");
     unsigned int choice; // user's menu choice
     scanf("%u", &amp;choice);
  
     // while user does not enter 3
     while (choice != 3) {
  
        switch (choice) { 
           // push value onto stack
           case 1:      
              printf("%s", "Enter an integer: ");
              scanf("%d", &amp;value);
              push(&amp;stackPtr, value);
              printStack(stackPtr);
              break;
           // pop value off stack
           case 2:      
              // if stack is not empty
              if (stackPtr != NULL) {
                 printf("The popped value is %d.\n", pop(&amp;stackPtr));
              }
  
              printStack(stackPtr);
              break;
           default:
              puts("Invalid choice.\n");
              instructions();
              break;
        } // end switch
  
        printf("%s", "? ");
        scanf("%u", &amp;choice);
     }
  
     puts("End of run.");
  }
  
  // display program instructions to user
  void instructions(void)
  { 
     puts("Enter choice:\n"
        "1 to push a value on the stack\n"
        "2 to pop a value off the stack\n"
        "3 to end program");
  }
  
  // insert a node at the stack top
  void push(StackNodePtr *topPtr, int info)
  { 
     StackNodePtr newPtr = malloc(sizeof(StackNode));
  
     // insert the node at stack top
     if (newPtr != NULL) {           
        newPtr-&gt;data = info;
        newPtr-&gt;nextPtr = *topPtr;
        topPtr = newPtr; 
     }                     
     else { // no space available
        printf("%d not inserted. No memory available.\n", info);
     } 
  }
  
  // remove a node from the stack top
  int pop(StackNodePtr *topPtr)
  { 
     StackNodePtr tempPtr = *topPtr;             
     int popValue = (*topPtr)-&gt;data;  
     *topPtr = (*topPtr)-&gt;nextPtr;
     free(tempPtr);               
     return popValue;
  }
  
  // print the stack
  void printStack(StackNodePtr currentPtr)
  { 
     // if stack is empty
     if (currentPtr == NULL) {
        puts("The stack is empty.\n");
     } 
     else { 
        puts("The stack is:");
  
        // while not the end of the stack
        while (currentPtr != NULL) { 
           printf("%d --&gt; ", currentPtr-&gt;data);
           currentPtr = currentPtr-&gt;nextPtr;
        }
  
        puts("NULL\n");
     } 
  }
  </code></pre>