please help

#include <cassert>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>


using namespace std;

void get(const string& askfor, string& input);
void get_password(const string& name, string& pwd);


void get(const string& askfor, string& input)
{
// this inputs a chracter array from input ... change it to input a string
cout << askfor<<": ";
cin>>input;
return;
}
void get_password(const string& name, string& pwd)
{


if(name == "botting")
pwd = "123456";
else if(name == "ernesto")
pwd = "765432";
else if(name == "tong")
pwd = "234567";
else
pwd = "qwert";
return;
}
int main()
{
// Change these character arrays to strings.

string name; string pwd; string passwd;
cout << "Address of name =" << &name <<"\n";
cout << "Address of pwd =" << &pwd <<"\n";
cout << "Address of passwd =" << &passwd <<"\n";

bool authenticated=false;
while(! authenticated)
{
// input the name here
get("Name", name);
// get the password pwd for the name
get_password(name, pwd);
// input a password passwd
get("Password", passwd);
// cout <<pwd<<" vs " <<passwd<<endl;
// compare the two passwords
if(pwd == passwd)
authenticated;
if (!authenticated)
cout << "Please try again\n";
}
cout << "Welcome "<<name<<"\n";

return 0;
}



i put unsername and the correct password but it still says please try again!
@elhamalz

Simple fix. You never change the bool variable authenticated, to true, if pwd is equal to passwd. Change 'authenticated;' to 'authenticated = true;', and you'll have a working program..
@whitenite1

Awesome it worked. Thank you for your help
You're very welcome, elhamalz
Topic archived. No new replies allowed.