title: Is it possible to initialize a C pointer to NULL?
body: <p>I had been writing things like </p>
  
  <pre><code>char *x=NULL;
  </code></pre>
  
  <p>on the assumption that </p>
  
  <pre><code> char *x=2;
  </code></pre>
  
  <p>would create a <code>char</code> pointer to address 2.  </p>
  
  <p>But, in <a href="http://www.crasseux.com/books/ctutorial/Pointers-and-initialization.html#Pointers%20and%20initialization" rel="noreferrer">The GNU C Programming Tutorial</a> it says that <code>int *my_int_ptr = 2;</code> stores the integer value <code>2</code> to whatever random address is in <code>my_int_ptr</code> when it is allocated.</p>
  
  <p>This would seem to imply that my own <code>char *x=NULL</code> is assigning whatever the value of <code>NULL</code> cast to a <code>char</code> is to some random address in memory.</p>
  
  <p>While</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      char *x=NULL;
  
      if (x==NULL)
          printf("is NULL\n");
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>does, in fact, print </p>
  
  <blockquote>
    <p>is NULL</p>
  </blockquote>
  
  <p>when I compile and run it, I am concerned that I am relying on undefined behavior, or at least under-specified behavior, and that I should write</p>
  
  <pre><code>char *x;
  x=NULL;
  </code></pre>
  
  <p>instead.</p>