Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. void wczytajDaneZProtokolu(string Protokol1, Student*& pHead1, Przedmiot*& pHead)
  2. {
  3.     fstream plik;
  4.  
  5.     plik.open(Protokol1);
  6.  
  7.     if (plik.good() == 0)
  8.     {
  9.         cout << "Plik jest bledny";
  10.         return;
  11.     }
  12.     else
  13.     {
  14.  
  15.  
  16.         Student* pomocniczy;
  17.         Student* nowyStudent;
  18.         Przedmiot* nowyPrzedmiot;
  19.         Przedmiot* pomocPrzedm;
  20.  
  21.  
  22.  
  23.         int n = 0;
  24.  
  25.         while (!plik.eof())
  26.         {
  27.             if (pHead) {
  28.                 pomocPrzedm = pHead;
  29.  
  30.                 while (pomocPrzedm)
  31.                 {
  32.                     if (pomocPrzedm->Nastepny == nullptr)
  33.                         pomocPrzedm = pomocPrzedm->Nastepny;
  34.                     else
  35.                         break;
  36.                 }
  37.                 nowyPrzedmiot = new Przedmiot;
  38.  
  39.                 pomocPrzedm->Nastepny = nowyPrzedmiot;
  40.  
  41.                 nowyPrzedmiot->Nastepny = nullptr;
  42.             }
  43.             else
  44.             {
  45.                 nowyPrzedmiot = new Przedmiot;
  46.  
  47.                 nowyPrzedmiot->Nastepny = nullptr;
  48.  
  49.                 pHead = nowyPrzedmiot;
  50.             }
  51.  
  52.             if (pHead->StNast) {
  53.                 pomocniczy = pHead->StNast;
  54.  
  55.                 while (pomocniczy)
  56.                 {
  57.                     if (pomocniczy->pNext == nullptr)
  58.                         pomocniczy = pomocniczy->pNext;
  59.                     else
  60.                         break;
  61.                 }
  62.                 nowyStudent = new Student;
  63.  
  64.                 pomocniczy->pNext = nowyStudent;
  65.  
  66.                 nowyStudent->pNext = nullptr;
  67.             }
  68.             else
  69.             {
  70.                 nowyStudent = new Student;
  71.  
  72.                 nowyStudent->pNext = nullptr;
  73.  
  74.                 pHead->StNast = nowyStudent;
  75.             }
  76.  
  77.  
  78.             getline(plik, pHead->Prowadzacy);
  79.             cout << pHead->Prowadzacy;
  80.  
  81.  
  82.  
  83.             getline(plik, pHead->Nazwa);
  84.             cout << pHead->Nazwa;
  85.  
  86.  
  87.  
  88.  
  89.             plik >> pHead->StNast->Imie >> pHead->StNast->Nazwisko >> pHead->StNast->Nr_Albumu >> pHead->StNast->Ocena >> pHead->StNast->Data;
  90.             cout << pHead->StNast->Imie << " " << pHead->StNast->Nazwisko << " " << pHead->StNast->Nr_Albumu << " " << pHead->StNast->Ocena << " " << pHead->StNast->Data;
  91.  
  92.  
  93.  
  94.         }
  95.         n = 0;
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement