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 50
|
int Admin::authentifier(string log,string pass)
{
Admin A;
int res;
ifstream myfile;
myfile.open ("admin.txt");
if(!myfile.is_open())
{
cout<<"Impossible d'ouvrir le fichier"<<endl;
}
else
{
while(!myfile.eof())
{
myfile>>A;
if((A.getlogin()==log)&&(A.getpassword()==pass))
{
res = 0;//verifier
}
else
{
res = -1;
}
}
myfile.close();
}
return res;
}
int main()
{string pass, log;
int trouve;
cout<<"donner le password";
//cinn>>pass;
getline(cin,pass);
cout<<"donner le login";
//cin>>log;
getline(cin,log);
trouve=authentifier(log,pass);
if (trouve==0)
{ cout<<"***********VOUS ETES BIEN L'ADMINISTRATEUR****************"<<endl;
........ //le traitement du logiciel
}
else
{
cout<<"******* DESOLER!!! VERIFIER LES INFORMATIONS********"<<endl;
} |
Partager