title: Proper Way to Free Memory of a Returned Variable
body: <p>I created a function designed to get user input. It requires that memory be allocated to the variable holding the user input; however, that variable is returned at the end of the function. What is the proper method to free the allocated memory/return the value of the variable?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>char *input = malloc(MAX_SIZE*sizeof(char*));
  int i = 0;
  char c;
  
  while((c = getchar()) != '\n' &amp;&amp; c != EOF) {
      input[i++] = c;
  }
  
  return input;
  </code></pre>
  
  <p>Should I return the address of input and free it after it is used?</p>
  
  <p>Curious as to the most proper method to free the input variable.</p>