title: Function returning address of local variable error in C
body: <p>I have the following code:</p>
  
  <pre><code> char* gen()
   {
       char out[256];
       sprintf(out, ...); // you don't need to know what's in here I don't think
  
       return out;
   }
  </code></pre>
  
  <p>And I am getting this error when I try to compile:</p>
  
  <pre><code>ERROR: function returns address of local variable
  </code></pre>
  
  <p>I've tried having this return <code>char[]</code> and <code>char</code> with no luck.  Am I missing something?</p>