title: While loop using realloc, won't update arrays when printing
body: <p>The code will not produce a compiler error, but i am trying to update the memory allocation after every loop if the user types <code>Y</code>, and increase the size of the memory. But after the first while loop, when i try to print the list of numbers using the first for loop, it will just show one number which will be <code>0.00000</code>. I can't get it to update (which is what I am trying to do in the second if loop). Any help is appreciated.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  int main()
  {
      double *userNum = (double*)malloc(sizeof(double));
      double sum = 0;
      char userChar = 'Y';
      int i = 0;
      int j = 0;
  
      if (userNum == NULL) {
              printf("Error with memory");
  
              return 1;
      }
  
      while (userChar == 'Y' || userChar == 'y') {
  
              printf("Enter a number\n");
              scanf("%lf", userNum);
  
              printf("List of numbers:\n");
              for (j; j &lt; (i + 1); j++) {
                      printf( "%lf\n", userNum[j]);
              }
  
              printf("More numbers (Y/N)? \n");
              getchar();
              scanf("%c", &amp;userChar);
  
  
              if (userChar == 'Y' || userChar == 'y') {
                      userNum = realloc(userNum, (i + 2) * sizeof(double));
                      i++;
              }
      }
  
      return 0;
  )
  </code></pre>