title: Pointers to pointers in C
body: <p>I'm trying to understand how pointers to pointers work and I came out with this example, and it compiles fine. But, when it is executed, I get a segmentation fault. 
  PS: I don't want <code>f1()</code> to return <code>char *</code>.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;assert.h&gt;
  
  int f1(char **str_);
  
  int main(int argc, char **argv)
  {
      char *str = NULL;
  
      f1(&amp;str);     
      printf("str : %s\n", *str);
  
      str = realloc(str, (size_t) 0);   
      assert(str == NULL);
  
      return 0;
  }
  
  int f1(char **str_)
  {
      if ((*str_ = realloc(*str_, sizeof(char) * 12)) == NULL)
      {
          fprintf(stderr,"realloc() failed\n");
          exit(3);
      }
  
      (*str_) = "hello there";
  
      return 0;
  }
  </code></pre>
  
  <ul>
  <li>What is wrong with the code?</li>
  </ul>