| 12
 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
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 
 | #include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
 
using namespace std;
 
 
 
 struct Adresse {
string Societe;
string ClientSite;
string ClientCompta;
string Groupe;
string Fjuri;
string Nom;
string Enseigne;
string Adresse1;
string Adresse2;
string Cpost;
string Ville;
string Tel;
string Fax;
string Email;
string Siret;
string Affacturage ;
};
 
istream & operator >> (istream & stream, Adresse & Client)
           {
            getline(stream, Client.Societe, ';');
            getline(stream, Client.ClientSite, ';');
            getline(stream, Client.ClientCompta, ';');
            getline(stream, Client.Groupe, ';');
            getline(stream, Client.Fjuri, ';');
            getline(stream, Client.Nom, ';');
            getline(stream, Client.Enseigne, ';');
            getline(stream, Client.Client1, ';');
            getline(stream, Client.Client2, ';');
            getline(stream, Client.Cpost, ';');
            getline(stream, Client.Ville, ';');
            getline(stream, Client.Tel, ';');
            getline(stream, Client.Fax, ';');
            getline(stream, Client.Email, ';');
            getline(stream, Client.Siret, ';');
            getline(stream, Client.Affacturage);
            return stream;
            }
 
ostream & operator << (ostream & stream, Adresse Client const & Client)
    {
        return stream
            << Client.Societe << " "
            << Client.ClientSite << " "
            << Client.ClientCompta << " "
            << Client.Groupe  <<  " "
            << Client.Fjuri << " "
            << Client.Nom << " "
            << Client.Enseigne << " "
            << Client.Client1 << " "
            << Client.Client2 << " "
            << Client.Cpost << " "
            << Client.Ville << " "
            << Client.Tel << " "
            << Client.Fax << " "
            << Client.Email << " "
            << Client.Siret << " "
            << Client.Affacturage;
    }
 
 
void afficherListeAdresse()
{
 
string ligne; //Une variable pour stocker les lignes lues
 
 
ifstream adresseClient("Adresseclients.csv");
    if(adresseClient)
    {
    //L'ouverture s'est bien passée, on peut donc lire
        while(getline(adresseClient, ligne)) //Tant qu'on n'est pas à la fin, on lit
        {
 Vector <Adresse> Client;
 Stream>>Client;
 
        }
 cout <<Client ;
    }
 
    else
    {
    cout << "ERREUR: Impossible d'ouvrir le fichier en lecture." << endl;
    }
 
    adresseClient.close(); //On referme le fichier
    //On ne peut plus écrire dans le fichier à partir d'ici
 
 
}
 
int main()
{
 
afficherListeAdresse();
 
    return 0;
} | 
Partager