title: returning int array when return type is int *
body: <p>I have a function that is described like this</p>
  
  <pre><code>int * oddNumbers(l, r, int* result_size){
     static int res[r-l];
     int index = 0;
     while(l &lt; r){
        if(l % 2 != 0){
           res[index] = l;
           index++;
        }
        l++;
  
     }
     result_size = &amp;index;
     return res;
  }
  </code></pre>
  
  <p>it is a problem question I have been given to solve. What I don't understand is how to return an integer array. I have looked up multiple ways to do this. Declaring the variable static, and allocating memory for the variable. </p>
  
  <p>I know the industry method for doing this is allowing the caller to allocate memory for the return value. But, unfortunately I do not have access to that part of the program only this function. </p>
  
  <p>Any help would be greatly appreciated.</p>