title: Does this situation require a delete or making a new variable?
body: <p>I'm creating some code to &quot;parse&quot; an IP address. Basically, I am working with some legacy code that only accepts IP addresses in the form &quot;AAA.BBB.CCC.DDD&quot; and would like to write in something like &quot;10.2.4.3&quot; and have the code work without needing to type in 010.002.004.003. The IP address is held in a char pointer and the function I wrote to add the zeros to the code returns another char pointer. Would the following main function be okay to use (i.e. no memory leaks or other issues)?</p>
  <pre><code>char* parser(char* ip) {
      char out[16];    //16 is the length of the final IP address with the dots and \0 char at the end
      //find output char array
      return out;
  }
  
  int main() {
      char *a=&quot;10.2.4.3&quot;;
      a=parser(a);
  
      return 0;
  }
  </code></pre>
  <p>While my understanding of memory leak issues in C++ are that they are due to allocating with new and then not deleting at the end or allocating with new and then reassigning them, I'm honestly not sure in this case. Since a is statically allocated, does assigning it to the char pointer created in the parser function cause any type of memory leak or other issue?</p>