Hello All,
I've been working through the book and have recently finished the chapter on functions. The problem I'm having is working practice problem three. I don't know why but my program keeps crashing every time I try and run it.
Code:
#include <iostream>#include <string>
using namespace std;
string check(string x, string y);
int main()
{
string username, password;
char choice;
for(;;)
{
cout << "Password Checking Program!" << endl;
cout << "Please enter your username and password: ";
cin >> username >> password;
cout << endl;
check(username, password);
cout << "Press c to continue and q to quit.";
if(choice == 'c')
{
continue;
}
else if(choice == 'q')
{
break;
}
else
{
cout << "I don't know what you wish to do returning to the program." << endl;
}
}
return 0;
}
string check(string x, string y)
{
if(x == "root" && y == "password")
{
cout << "Access granted." << endl;
}
else
{
cout << "Please try again." << endl;
}
}