Well, how about this.
*shakes head*
After playing some more I finally figured it out. The file stream was going into failstate, so just closing and reopening a file isnt going to work in this instance. So, I used the magical:
file.clear();
And now...it works like a charm. Amazing, the simplest things can be the hardest to figure out.
Thanks for all your help everyone!
Here is the code for example:
PHP Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void main()
{
int count;
float num;
float total;
float avg;
ifstream inData;
ofstream outData;
// lets get them all on one line
inData.open("datfile1.txt");
outData.open("outdata.txt");
while(inData >> num)
{
outData << num << " ";
}
outData << endl;
inData.clear();
inData.seekg(0);
count = 0;
avg = 0;
total = 0;
outData << fixed << showpoint
<< setprecision(3);
while(inData >> num)
{
total += num;
count++;
}
avg = total / count;
outData << avg << endl;
inData.close();
}