1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <Perso.h>
using namespace std;
void lecture_remplissage(vector<Perso>& feu, vector<Perso>& terre, vector<Perso>& air, vector<Perso>& eau)
{
ifstream fichier;
string metal, element, chaussure, arme;
fichier.open("text.txt", ios::in);
if(fichier) // si l'ouverture a réussi
{
fichier >> metal>> element>> chaussure>> arme;
Perso P1 (metal, element, chaussure, arme);
if(element=="feu")
{
feu.push_back(P1);
cout<<"Et un perso feu de plus. "<<endl;
}
if(element=="eau")
{
eau.push_back(P1);
cout<<"Et un perso eau de plus. "<<endl;
}
if(element=="terre")
{
terre.push_back(P1);
cout<<"Et un perso terre de plus. "<<endl;
}
if(element=="air")
{
air.push_back(P1);
cout<<"Et un perso air de plus. "<<endl;
}
if(element!="air" && element!="terre" && element!="eau" && element!="feu")
{
cout<<"Erreur: categorie non reconnue. "<<endl<<endl;
}
fichier.close();
}
else
{
cout << "Erreur: Ouverture fichier impossible !" << endl;
}
}; |
Partager