title: checking if malloc'ed pointer is NULL
body: <p>I have the following code (simplified for here).</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  struct inner {
      int a;
      int b;
  };
  
  struct outer {
      struct inner *next;
      struct inner *prev;
  
  };
  
  
  int main(int argc, char *argv[]) {
      struct outer *c = malloc(sizeof(struct outer));
  
      if (c-&gt;next) {
          printf("here\n");
      }
  
      if (c-&gt;next != NULL) {
          printf("here too");
      }
  }
  </code></pre>
  
  <p>As you can see above, <code>c</code> only has memory allocated, so <code>c-&gt;next</code> and <code>c-&gt;prev</code> are NULL addresses. But both print statements still run. How do I get the <code>if</code> statement to work only if <code>c-&gt;next</code> is not a null pointer?</p>