title: How to dynamically allocate an array of integers in C
body: <p>A portion of my C code is shown below.    </p>
  
  <pre><code>int data[10]={1,3,6,8,1,7,9,1,1,1}; 
  b=10;
  int out[b];
  process(data, &amp;b, out);
  alpha (out, b);
  </code></pre>
  
  <p>data and out are  int arrays. The function process takes the array data whose length is pointed by b (=10) and performs mathematical operation and then returns an array out whose length is then again returned by b (unknown and hence required to be dynamically allocated). Then the array out is sent with function alpha. Right now the function alpha always sends out[10] since b has been declared as 10 in second line of code. How can I allocate array out dynamically so that it contains only valid data returned after function process.</p>