Why can't I retrieve simple data from an input file and write it to an output file with C++?
<p>I've been at this homework for days, and I cannot figure out what exactly I am doing wrong.</p>

<p>In short, I am building a simple, basic program in C++ that reads a student name and 5 grades from a file called input.dat, and then writing that data, and organizing it into a separate file called output.dat.</p>

<p>Simple, right?
However, when I check the output file, instead of simple whole numbers, I get insane, exponentially large numbers that repeat themselves.</p>

<p>Please help me out. And go easy on me. I'm 18 and this is my first programming class ever. </p>

<p>Here is my code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;

using namespace std;

int main()
{
    ifstream in_stream;
    ofstream out_stream;
    in_stream.open("input.dat");
    out_stream.open("output.dat");

    double test1, test2, test3, test4, test5;
    string name1, name2;

    cout.precision(2);
    cout.setf(ios::showpoint);

    in_stream &gt;&gt; name1 &gt;&gt; name2 &gt;&gt; test1 &gt;&gt; test2 &gt;&gt; test3 &gt;&gt; test4 &gt;&gt; test5;

    out_stream &lt;&lt; "Student Name: " &lt;&lt; name1 &lt;&lt; name2 &lt;&lt;endl
        &lt;&lt; "Test Scores: " &lt;&lt; test1 &lt;&lt; test2 &lt;&lt; test3 &lt;&lt; test4 &lt;&lt; test5 &lt;&lt;endl
        &lt;&lt; "Average Test Score: " &lt;&lt; ((test1 + test2 + test3 + test4 + test5)/5);

    in_stream.close( );
    out_stream.close( );

    system("pause");
    return 0;
}
</code></pre>
