Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
bool LoggedIn()
{
string username, password, name /*comparasion string */, code /*comparasion string */;
cout << "Enter Username: "; cin >> username;
cout << "Enter Password: "; cin >> password;
ifstream read("c:\\Users\\Rahul\\source\\repos\\RegisterAndLogin\\RegisterAndLogin\\LoginDetails\\" + username + ".txt"); //ifstream for reading a file// """ looking for the filename username """
getline(read, name); // the read line for username
getline(read, code); // the read line for password
if (name == username && code == password) {
return true;
}
else {
return false;
}
}
int main()
{
int option;
cout << "1: Registration\n2 : Login\nYour option: "; cin >> option;
if (option == 1) {
string fullname, username, password;
cout << "Enter Full Name: ";
cin >> fullname;
cout << "Create a username: ";
cin >> username;
cout << "Enter a password: ";
cin >> password;
ofstream file; //ofstream for creating a file
file.open("c:\\Users\\Rahul\\source\\repos\\RegisterAndLogin\\RegisterAndLogin\\LoginDetails\\" + username + ".txt"); //open file
file <<fullname << endl << username << endl << password;
file.close(); //close file
main();
}
else if (option == 2) {
bool status = LoggedIn;
if (!status)
{
cout << "Unable to login, please check your username or password" << endl;
system("PAUSE");
return 0; //return 0 as "int" main
}
else {
cout << " Logged in successfully!" << endl;
system("PAUSE");
return 1;
}
}
}
};