Advertisement
Alx09

Untitled

Nov 25th, 2020
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. void citire_fisier(string numeFiser)
  2. {
  3.     ifstream f(numeFiser);
  4.     int marime;
  5.     double pret;
  6.     string nume, brand, material, culoare;
  7.     char tip;
  8.     if (!f) {
  9.         cout << "\n Nu exista fiserul " <<  numeFiser;
  10.         return;
  11.     }
  12.     while (!f.eof()) {
  13.         f >> tip;
  14.         f >> nume;
  15.         f >> pret;
  16.         if (tip == 'H') {
  17.             f >> culoare;
  18.             f >> marime;
  19.                 listaCadou.push_front(new Haina(nume, pret, culoare, marime));
  20.         }
  21.         if (tip == 'B') {
  22.             f >> material;
  23.                 listaCadou.push_front(new Bijuteri(nume, pret, material));
  24.            
  25.         }
  26.         if (tip == 'J') {
  27.             f >> brand;
  28.             listaCadou.push_front(new Jucarie(nume, pret,  brand));
  29.    
  30.         }
  31.     }
  32.     cout << "\n Datele au fost citite cu succes!";
  33.     f.close();
  34.     //else throw "Eroare la citirea din fisier";
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement