I am writing to a file the ios fixed and show point works fine through out the loop but ios left only works on my file from the second set of data on. The first set of data still stays shifted right.
Here is the code, thanks in advance.

void StudentArrayV4::write(ofstream& outfile){
   
   if(!outfile){
      cout << "File error data could not be saved!\n";
   }
   else{
       outfile << setw(40) << "scores\n" << setiosflags (ios::left)
       << setw(10) <<"name" << setw(11) << "ID  "
      << setw(8) << "1" << setw(10)  << "2" << setw(10)  << "3"
      << setw(13) << "avg  " << setw(11) << "grade\n" << resetiosflags(ios::left);
      for (int j =0; j < numberOfStudents; j++){
         members[j] -> write(outfile); // student::write
      }
   }
}

void Student::write(ofstream& outfile){
         outfile << setiosflags(ios::left) << setw(10) <<  name << setw(10)
         << idNumber << setw(10) << scores[0] << setw(10) << scores[1]
         << setw(10) << scores[2] << setw(10) << setprecision(2)
         << setiosflags(ios::fixed | ios::showpoint) << setprecision(2) << average
         << setw(10) << grade << resetiosflags(ios::fixed | ios::left | ios::showpoint) <<"\n";
}

Put newline or endl,

void Student::write(ofstream& outfile){
         outfile << endl << setiosflags(ios::left) << setw(10) <<  name 
         ....
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.