title: How can I assign variables directly from a text file?
body: <p>I'm writing a C++ project, but I'm running into some issues. I have a text file:</p>
  
  <pre><code>5.123456789
  9.987654321
  6
  </code></pre>
  
  <p>I would like to have an assignments like this:</p>
  
  <pre><code>double firstLine = 5.123456789;
  double secondLine = 9.987654321;
  int thirdLine = 6;
  </code></pre>
  
  <p>How could I assign the values directly from the text file?</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>string line = "";
  ifstream infile;
  infile.open("xinput.txt");
  while(getline(infile,line))
      {
          //I suppose this is where I would have to insert my missing code,
          //but I am unsure how to proceed.
      }
  infile.close();
  </code></pre>