title: Writing out an array using fprintf
body: <p>I'm having trouble writing an array of double numbers in a text file. The problem is, the code runs, but doesn't write out anything.</p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;stdlib.h&gt;
  
   int main() {
  
       FILE *out;
       double numbers[30];
       int i=0;
  
       for(i;i&lt;30;i++) 
           scanf("%lf", &amp;numbers[i]);
  
       out=fopen("out.txt", "w");
  
       if (out == NULL) {
  
           fprintf(stderr, "error in opening .txt");
           exit(EXIT_FAILURE);
       }
  
       while ( i&lt;30 ) {
  
           fprintf(out, "%.3f", numbers[i]);
           i++;
       }
  
       fclose(out);
  
       return 0;
   }
  </code></pre>
  
  <p>Basically, the code is supposed to write out an array of 30 double numbers in a text file, and round the decimals to '.3'.</p>