How do i make a code so that i can open a file if the person that is using it types 1 for yes or 2 for no
Heres my code,
#include <iostream>
#include <fstream>
using namespace std;
int main(){
// for logging in
int Pass, Name;
Pass = 159876;
Name = 159874;
int PassIn;
int NameIn;
// for opening the password and username files
int a, b;
a = 1;
b = 1;
int d;
int e;
cout << "Please Enter your Username:";
cin >> NameIn;
cout << "Please Enter a Password:";
cin >> PassIn;
if (NameIn != Name || PassIn != Pass){
cout << "Incorrect Username/Password Combintation \n";
}
if (NameIn == Name && PassIn == Pass){
cout << "What would you like to do: (1 for Yes/ 2 for No) \n";
cout << "a) Access the password list \n";
cin >> d;
if (d == a){
fstream passw;
passw.open ("password.txt");
}
cout << "b) Access the username list \n";
cin >> e;
if (e == b){
fstream usern;
usern.open ("username.txt");
}
cout << "c) Exit \n";
}
system("pause");
return 0;
}