title: Why can't I use an if statement instead of using assert in C++?
body: <p>Since <code>assert</code> simply checks if the statement in its parameter holds true or not, why don't we simply use an <code>if</code> condition to check that?</p>
  
  <blockquote>
    <p>Usage of assert</p>
  </blockquote>
  
  <pre><code>void print_number(int* somePtr) {
    assert (somePtr !=NULL);
    printf ("%d\n",*somePtr);
  }
  </code></pre>
  
  <blockquote>
    <p>Usage of if</p>
  </blockquote>
  
  <pre><code>void print_number(int* somePtr) {
    if (somePtr != NULL)
         printf ("%d\n",*somePtr); 
  }
  </code></pre>
  
  <p>Can anybody point out the difference between the two and advantages of using one over the other?</p>
  
  <p>Also, why do most people prefer <code>assert</code> over <code>if</code> here?</p>