title: Read an array recursively
body: <p>I am learning how to apply recursion to arrays.</p>
  
  <p>For example, I usually read arrays itiratively, this way:</p>
  
  <pre><code>void read_array(int *a, int n){
          int i;
          for(i = 0; i &lt; n; ++i)
                  scanf("%d", &amp;a[i]);
          return;
  }
  </code></pre>
  
  <p>I would like to read an array recursively. I wrote the following function:  </p>
  
  <pre><code>void read_array(int *a, int n){
          int i = n - 1;
          if (n &lt; 0)
                  return;
          else{
                  if(scanf("%d", &amp;a[n - 1 - i]) == 1){
                          read_array(a, n - 1);
                          return;
                  }
          }
  }
  </code></pre>
  
  <p>It compiles, but when running it trows a segmentation fault error. It confuses me since the function contemplates a base case <code>0</code> that should stop it. </p>