title: C Random Number generator returning address
body: <p>A part of my code is to randomly generate an array with numbers between 0 and 999. I do this with a random number generator. However everytime it does it and returns the array, the <code>intArray[8]</code> to <code>intArray[12]</code> have what I presume is the address. How can I fix this. I have printed each part of the array in the randomArr function and they are fine.</p>
  <p>Code</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include&lt;time.h&gt;
  #include &quot;sorting.h&quot;
  
  
  void initRandom()
  {
      srand(time(NULL));
  }
  
  int random(int low, int high)
  {
      int number = -1;
  
      if(low &lt;= high)
      {
          number = (rand() % (high-low+1)) + low;
      }
  
      return number;
  }
  
  void randomArr(int* numArray, int intNum){
      int j = 0;
      initRandom();
      for (j = 0; j &lt; intNum; j++){
          numArray[j] = random(0, 999);
      }
  } 
  
  int main(int argc, char* argv[]){
      int* intArray = (int*)malloc(sizeof(double));
      if (argc &lt; 2){
          printf(&quot;Error! Not enough arguments!&quot;);
      } else if (argc &gt; 3){
          printf(&quot;Error! Too many arguments!&quot;);
      } else{
          int intNum, i;
  
          if (argc == 2){
              printf(&quot;Please specify number of integers: &quot;);
              scanf(&quot;%d&quot;, &amp;intNum);
              randomArr(intArray, intNum);
  
          }
          for (i = 0; i &lt; intNum; i++){
              printf(&quot;Num %d: %d\n&quot;, i+1, intArray[i]);
          }
      }
      free(intArray);
      return 0;
  }
  </code></pre>
  <p>One output example with 20 ints is:</p>
  <pre><code>./sorting 1
  Please specify number of integers: 20
  Num 1: 97
  Num 2: 971
  Num 3: 579
  Num 4: 223
  Num 5: 905
  Num 6: 883
  Num 7: 711
  Num 8: 757
  Num 9: 544044366
  Num 10: 891304505
  Num 11: 858863928
  Num 12: 842609462
  Num 13: 2610
  Num 14: 283
  Num 15: 568
  Num 16: 319
  Num 17: 426
  Num 18: 443
  Num 19: 848
  Num 20: 572
  </code></pre>