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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!