canezzy

binispis

Dec 4th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. if (binarna == true) {
  2.  
  3.         file.open(path, ios::out | ios_base::binary);
  4.         const char tabulator = '\t';
  5.         const char newline = '\n';
  6.         if (!file) {
  7.             std::cout << "Error in creating output file...\n";
  8.         }
  9.         for (StudentCourses sc : get_student_courses()) {
  10.             for (char c : sc.get_student().get_first_name()) {
  11.                 file.write(&c, sizeof(char));
  12.             }
  13.             file.write(&tabulator, sizeof(char));
  14.             for (char c : sc.get_student().get_last_name()) {
  15.                 file.write(&c, sizeof(char));
  16.             }
  17.             file.write(&tabulator, sizeof(char));
  18.             for (char c : sc.get_student().get_id()) {
  19.                 file.write(&c, sizeof(char));
  20.             }
  21.             file.write(&tabulator, sizeof(char));
  22.             double fs = sc.get_final_score();
  23.             file.write(reinterpret_cast<char*>(&fs), sizeof(double));
  24.             file.write(&tabulator, sizeof(char));
  25.             char lg = sc.get_courses().get_letter_grade();
  26.             file.write(&lg, sizeof(char));
  27.             file.write(&newline, sizeof(char));
  28.  
  29.            
  30.         }
  31.         file.close();
  32.  
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment