title: Checking NULL Pointer In C Doesn't Work
body: <p>I have a function which returns a multiple indirection pointer as result like so:</p>
  
  <pre><code>typedef struct {
      int id;
      char *name;
  } user;
  
  user **myfn(int users_count) {
      user **a;
      a = malloc(sizeof(user) * user_counts);
      for(int i = 0 ; i&lt;user_counts ; i++) {
          *(a+i) = malloc(sizeof(user));
          (*(a+i))-&gt;id = 1;
          (*(a+i))-&gt;name = malloc(sizeof(char) * 25);
          strncpy((*(a+i))-&gt;name, "Morteza", 25); // just for example
      }
      return a;
   }
  </code></pre>
  
  <p>Now, I when I want to crawl in this result in main function, it will show all users name, but at the end it will encounter with <code>Segmentation fault</code> error.</p>
  
  <pre><code>int main() {
      user **a = myfn(10);
      int i = 0;
      while((*(a+i)) != NULL) {
          printf("ID: %d \t %s\n", (*(a+i))-&gt;id, (*(a+i))-&gt;name);
          i++;
      }
  }
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>ID: 1 Morteza
  ID: 2 Morteza
  ...
  ...
  ID: 10 Morteza
  Segmentation fault (core dumped)
  </code></pre>
  
  <p>Why <code>condition</code> of <code>while</code> doesn't work fine?</p>