hello i used another way in the copy function and i asked my teacher to use this way and she said it is ok... The problem is ( i think ) how to move from one line to another after copying it from the input file and adding the average to it???? this is my function i know it looks stupid but what can i do???
Code:
void copy ( ifstream& input_file , ofstream& output_file )
{
char first_name[20] , last_name[20] ;
int sum,num1,num2,num3,num4,num5 ;
int num6,num7,num8,num9,num10;
double average ;
while ( ! input_file.eof() )
{
input_file >> last_name ;
output_file << " " << last_name ;
input_file >> first_name ;
output_file << " " << first_name ;
input_file >> num1 ; output_file << " " << num1 ;
input_file >> num2 ; output_file << " " << num2 ;
input_file >> num3 ; output_file << " " << num3 ;
input_file >> num4 ; output_file << " " << num4 ;
input_file >> num5 ; output_file << " " << num5 ;
input_file >> num6 ; output_file << " " << num6 ;
input_file >> num7 ; output_file << " " << num7 ;
input_file >> num8 ; output_file << " " << num8 ;
input_file >> num9 ; output_file << " " << num9 ;
input_file >> num10 ; output_file << " " << num10 ;
output_file.setf(ios::fixed);
output_file.setf(ios::showpoint);
output_file.precision(2);
sum = num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10;
average = double(sum) / 10 ;
output_file << " Average = " << average << endl << endl ;
}
}