title: Is it valid to pass a pointer to a stack variable to realloc()?
body: <pre><code>int main()
  {
     char myString = NULL;
     realloc(&amp;myString, 5);
     strncpy((char *)&amp;myString, "test", 5);
  }
  </code></pre>
  
  <p>Seems to work fine but I'm still slightly confused about stack vs heap. Is this allowed? If it is allowed, does <code>myString</code> need to be freed manually or will it be released when it goes out of scope?</p>
  
  <hr>
  
  <p>Edit: Thanks for the responses, so i presume this is equally illegal</p>
  
  <pre><code>//I want the code to change myString to "tests"
  char myString[5] = "test";
  realloc(&amp;myString, strlen(myString)+2);
  myString[4] = 's';
  myString[5] = '\0';
  </code></pre>