title: How to store float numbers in array C++
body: <p>I'm working with a project, but I can't find a way to store float numbers in a array. I have a .txt file (testfile.txt) with float numbers, like this</p>
  
  <pre><code>1.0 2.0
  3.0 4.0
  5.0 6.0
  7.0 8.0
  9.0 10.0
  </code></pre>
  
  <p>And I want to store it into a array. But when I do this, all my numbers are converted to integers. My program looks like this:</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      double number[10];
  
      ifstream infile;
      infile.open("testfile.txt");
      for(int a=0; a&lt;10; a=a+1)
      {
        infile &gt;&gt;  number[a]; // Reading from the file
        cout &lt;&lt; number[a] &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>And the output is like this</p>
  
  <pre><code>1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  </code></pre>
  
  <p>Can someone please explain to me what I'm doing wrong? I have tried a lot, thanks in advance!</p>