 <p>The std::getline function you're using saves an input to a string (see: <a href="http://www.cplusplus.com/reference/string/string/getline/" rel="nofollow">http://www.cplusplus.com/reference/string/string/getline/</a>). If the argument you pass to the function was a string, it would get the whole line from your file, which is "0 50 100" and put it in your string.</p> <p>You could trying to save it to a string and then splitting it to three parts and converting to ints using atoi or std::stoi in C++11 (check <a href="http://stackoverflow.com/questions/7663709/convert-string-to-int-c">Convert string to int C++</a>) - this way it would be easier to handle possible errors. </p> <p>But there's an easier way to do it - assuming your numbers are split by spaces and pretty much everything is correct with them, the ">>" operator breaks on spaces. Try:</p> <pre><code>inFile &gt;&gt; inVal1; inFile &gt;&gt; inVal2; inFile &gt;&gt; inVal3; </code></pre> <p>Also, using cin.ignore() is not necessary when using the inFile buffer. Every stream has a different buffer associated with it (and cin != inFile) so you don't need to clear the cin buffer to read from your file.</p>