Advertisement
Guest User

Untitled

a guest
May 27th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. void fileOut(char * nameOfFile, int &numOfStud) // эта функция выводит содержимое нашего файла
  2. {
  3. if (numOfStud == 0) // если количество студентов равно 0, то и выводить ничего не нужно
  4. return;
  5. ifstream fin;
  6. fin.open(nameOfFile);
  7. if (!fin)
  8. {
  9. error("Cannot open the file!", 500); // это моя функция. Она просто выводит на экран сообщение на заданное время
  10. return;
  11. }
  12. student stud; // тут будет храниться текущая структура (нужно поменять на свою)
  13. for (int i = 0; i < numOfStud; i++)
  14. {
  15. fin.read((char*)&stud, sizeof(stud));
  16. outputStruct(stud); // функция выводит структуру (тоже поменять на свою)
  17. cout << endl;
  18. }
  19. system("pause");
  20. system("cls");
  21. }
  22.  
  23. void outputStruct(student stud) // выводит структуру
  24. {
  25. cout << "Struct #" << stud.numOfStud << endl;
  26. cout << "Name: " << stud.fullName.name << endl;
  27. cout << "Last name: " << stud.fullName.lastName << endl;
  28. cout << "Patronymic: " << stud.fullName.patronymic << endl;
  29. cout << "Gender: " << stud.gender << endl;
  30. cout << "Nationality: " << stud.nationality << endl;
  31. cout << "Hight: " << stud.hight << endl;
  32. cout << "Wight: " << stud.wight << endl;
  33. cout << "Year of birth: " << stud.dateOfBirth.year << endl;
  34. cout << "Month of birth: " << stud.dateOfBirth.month << endl;
  35. cout << "Date of birth: " << stud.dateOfBirth.date << endl;
  36. cout << "Phone number: " << stud.phoneNumber << endl;
  37. cout << "Postcode: " << stud.address.postcode << endl;
  38. cout << "Country: " << stud.address.country << endl;
  39. cout << "Region: " << stud.address.region << endl;
  40. cout << "District: " << stud.address.district << endl;
  41. cout << "Town: " << stud.address.town << endl;
  42. cout << "Street: " << stud.address.street << endl;
  43. cout << "House: " << stud.address.house << endl;
  44. cout << "Apartment number: " << stud.address.apartmentNumber << endl;
  45. cout << "#High school#\nName: " << stud.highSchool.name << endl;
  46. cout << "Course: " << stud.highSchool.course << endl;
  47. cout << "Group: " << stud.highSchool.group << endl;
  48. cout << "Average grade: " << stud.highSchool.averageGrade << endl;
  49. cout << "Specialty: " << stud.highSchool.specialty;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement