Reading file integers into an int array

This code is suppose to copy the contents of gradefile.txt to gradeout.txt. Then it is suppose to read gradefile.txt again using a different ifstream variable and store the integers in an int array. (Assume that there are at most 100 scores). Find the number of scores in this file, maximum score, minimum score and average score. Now, open the file gradeout.txt, this time with the option to append. Output all of these values BOTH to the screen and to the file gradeout.txt. The average must be a double and should put exactly 2 places after the decimal point. (So you need to do necessary formatting). APPEND these data to the file gradeout.txt. So far I have the first part coded where I have to copt the contents of one file into another using a string. Now I am getting stuck. How do I get integers into an array if they are separated by a lot of blank spaces? I would appreciate any guidance/help I could get on where to go from here.

Thanks


#include <fstream>
#include <iostream>
#include <cstdlib>

using namespace std;
int main()
{

using namespace std;

ifstream in_stream, in_stream2;
ofstream out_stream;


in_stream.open("gradefile.txt");
if (in_stream.fail( ))
{
cout << "Input file opening failed.\n";
exit(1);
}
out_stream.open("gradeout.txt");
if (out_stream.fail( ))
{
cout << "Output file opening failed.\n";
exit(1);
}

char next_symbol;

while (!in_stream.eof())
{
in_stream.get(next_symbol);
out_stream << next_symbol;
}

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

in_stream2.open("gradefile.txt");
if (in_stream2.fail( ))
{
cout << "Input file opening failed.\n";
exit(1);
}

int grade_array[100];


int i=0;
while (!in_stream.eof())
{
in_stream2 >> grade_array[i];
i++;

}



return 0;
}
Topic archived. No new replies allowed.