title: How to make an array return type from C function?
body: <p>I have tried to return the array name as shown below. Basically I am trying to make the function test return an array that can be used in main. Could you advise me as to what I need to read into more to find out how to perform a function like this?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int test(int size, int x){
      int factorFunction[size];    
      factorFunction[0] = 5 + x;
      factorFunction[1] = 7 + x;
      factorFunction[2] = 9 + x;
      return factorFunction;
  }
  
  int main(void){
      int factors[2];
      factors = test(2, 3);
      printf("%d", factors[1]);
      return 0;
  }
  </code></pre>
  
  <p>I receive the compiler errors:</p>
  
  <pre><code>smallestMultiple.c:8: warning: return makes integer from pointer without a cast
  smallestMultiple.c:8: warning: function returns address of local variable
  smallestMultiple.c: In function ‘main’:
  smallestMultiple.c:13: error: incompatible types in assignment
  </code></pre>