title: How do I check if a pointer points to NULL?
body: <p>The title may be a little bit of a misnomer... just because I'm not sure if my char pointer is pointing to NULL, or if it's just pointing to a char array of size 0.</p>
  
  <p>So I have </p>
  
  <pre><code>char* data = getenv("QUERY_STRING");
  </code></pre>
  
  <p>And I want to check if data is null (or is length &lt; 1). I've tried:</p>
  
  <pre><code>if(strlen(data)&lt;1) 
  </code></pre>
  
  <p>but I get an error:</p>
  
  <pre><code>==24945== Invalid read of size 1
  ==24945==    at 0x8048BF9: main (in /cpp.cgi)
  ==24945==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
  </code></pre>
  
  <p>I've also tried</p>
  
  <pre><code>if(data == NULL)
  </code></pre>
  
  <p>but with the same result.</p>
  
  <p>What's going on here? I've already tried cout with the data, and that works fine. I just can't seem to check if it's null or empty.</p>
  
  <p>I realize these are two different things (null and empty). I want to know which one data would be here, and how to check if it's null/empty.</p>