Question: #include #include #include using namespace std; int main() { int choice; cout < < 1: Register 2: Login Your Choice: ; cin >> choice; if
#include
#include
#include
using namespace std;
int main()
{
int choice;
cout << "1: Register 2: Login Your Choice: ";
cin >> choice;
if (choice == 1)
{
string username, password;
cout << "Select a user name: " << endl;
cin >> username;
cout << "Select a password: " << endl;
cin >> password;
ofstream file;
file.open("data\\" + username + ".txt");
file << username << endl << password;
file.close();
main();
}
else if (choice == 2)
{
string username, password, un, pw;
cout << "Enter user name: " << endl;
cin >> username;
cout << "Enter password: " << endl;
cin >> password;
ifstream read("data\\" + username + ".txt");
getline(read, un);
getline(read, pw);
if (un == username && pw == password)
{
cout << "Successfully logged in!" << endl;
}
else
{
cout << "False Login!" << endl;
}
}
system("pause");
return 0;
}
How do I correct this coding?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
