title: C free variables declared inside function
body: <p>Imagine this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #define MAXSTRSIZE 2048    
  
  int main()
  {
      char *str;
  
      str = get_string();
  
      return 0;
  }
  
  char * get_string()
  {
      char temp[MAXSTRSIZE], *str;
  
      fgets(temp,MAXSTRSIZE,stdin);
      str = malloc( sizeof(char) * (strlen(temp) + 1) );
      strcpy(str, temp);
  
      return str;
  }
  </code></pre>
  
  <p>Do I need to free() the <code>temp</code> variable in function <code>get_string</code>?
  What if did the <code>get_string</code> code inside the <code>main()</code>?</p>