title: C++ read integers from file and save into array
body: <p>I'm making a program that reads only integers from text file.  I want to make a function that reads integers and stores them in an array so I can use that array later to sort them with bubble sort. This is what I have so far but the output I get is some random -803234.... number :</p>
  
  <pre><code>void read(int A[max], int&amp; numbers) { 
      ifstream file("ints.txt");
      if (file.is_open()) {
          file &gt;&gt; numbers;
  
          for (int i = 0; i &lt; numbers; i++) {
              cout &lt;&lt; "numbers: " &lt;&lt; A[i] &lt;&lt; endl;
          }
          file.close();
      }
      cout &lt;&lt; "numbers in array: " &lt;&lt; A[numbers] &lt;&lt; endl;
  }
  </code></pre>