title: storing input into malloc array (1d and 2d) and printing
body: <p>I am tryin to take input from the user and store it into an array and print it out: i have 2 functions: </p>
  
  <pre><code> /* Read a vector with n elements: allocate space, read elements,
      return pointer */
  double *read_vector(int n){
      double *vec = malloc(n * sizeof(double));
  
      int i;
      for (i = 0; i &lt; n; i++)
         vec[i] = n;
  
      return vec;
  }
  </code></pre>
  
  <p>and the print function is:</p>
  
  <pre><code>void print_vector(int n, double *vec){
      int i;
      for (i = 0; i &lt; n; i++) {
         printf("%d\n", vec[i]);
      }
  }
  </code></pre>
  
  <p>the main function is:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  double *read_vector(int n);
  void print_vector(int n, double *vec);
  void free_vector(double *vec);
  
  int main(){
      int n;
      double *vector;
      /* Vector */
      printf("Vector\n");
      printf("Enter number of entries: ");
      scanf("%d", &amp;n);
      printf("Enter %d reals: ", n);
      vector = read_vector(n);
      printf("Your Vector\n");
      print_vector(n,vector);
      free_vector(vector);
  }
  </code></pre>
  
  <p>when i run this, it does not let me enter any numbers, it just skips it and prints out 0's. How do i fix this?</p>