title: how to return value before deleting it?
body: <p>I would like to jump over two nodes, in order to have access to penultimate node as well as last node:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct node {
      int value;
      struct node *next;
  };
  typedef struct node node_t;
  
  //prototypes
  node_t *create(int);
  node_t *push(node_t *, node_t **);
  node_t *shift(node_t *);
  
  int main(void){
      node_t *h = 0;
  
      for(int i =0; i&lt;23 ; i++)
          push(create(i+1),&amp;h);
  
      shift(h);
  
  }
  
  node_t *create(int value){
      node_t *new = malloc(sizeof(node_t));
      new-&gt;value=value;
      //new-&gt;next=0;
      return new;
  }
  
  node_t *push(node_t *new, node_t **head){
      new-&gt;next = *head;
      *head=new;
      return new;
  }
  
  node_t *shift(node_t *head){
      node_t *tmp = head; //do not change head pointer
      for(;tmp;tmp=tmp-&gt;next-&gt;next); //jump over 2 nodes, to have access to last node and penultimate
      node_t *last = tmp-&gt;next; //one before null node (the very last), the one I want return;
      tmp-&gt;next = 0; //now delete it, so last node will become penultimate one
      return last;
  }
  </code></pre>
  
  <p>But that would gives - <code>command terminated</code>. I know i am returning null, but how can I return before delete the node? Because return is the last command to be executed, it has to be the last. But then I am returning 0. How to get from that?</p>