title: Returning an array of variable size in c from a function
body: <p>So i want to return an array of a size <code>n</code> (variable) which my function has as input. I know that in order to return arrays in C I have to define them <code>static</code>, but the problem is that <code>n</code> is a variable and thus I get an error. I thought of actually using <code>malloc</code>/<code>calloc</code> but then I won't be able to <code>free</code> them after the function returns the array. Please take note that I'm not allowed to change anything on <code>main()</code>. Are there any other alternatives which I could use? Thanks in advance.</p>
  
  <pre><code>float *Arr( int *a , int n ){
      static float b[ n ];
      return b
  }
  </code></pre>
  
  <p>Got to point out that the function will only be called Once,I saw the solution you posted but i noticed you aren't freeing the allocated memory,is it not of much importance when the malloc is called inside a function?</p>