title: How do I free a pointer returned from a function?
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  char* f(void) {
    char *x;
    x = malloc(sizeof(char) * 4);
    strcpy(x, "abc");
    return(x);
  }
  
  int main(void) {
    char *a;
    a = f();
    printf("%s", a);
    free(a);
    return(0);
  }
  </code></pre>
  
  <p>Does the variable <code>x</code> in the function have to be freed? If so, how is that possible when I need to return it?</p>