-
-
Save anonymous/2514efea38a305d0ea66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <fstream> | |
#include <iomanip> | |
#include <ctype.h> | |
using namespace std; | |
void main() | |
{ | |
ifstream infile,inputfile; | |
fstream myfile; | |
string nameadd, name, passwordadd, password, useradd, user, user1, password1; | |
string answer; | |
char choice; | |
infile.open("personal.txt"); | |
cout << "Are you a member? Y or N :"; | |
cin >> answer; | |
if (answer == "n") | |
{ | |
myfile.open("personal.txt", fstream::app); | |
if (!myfile) | |
cout << "unable to open"; | |
else | |
{ | |
cout << "Please enter name. 'no spacing is allowed, please use _ ' "; | |
cin >> nameadd; | |
cout << "Please enter username. : "; | |
cin >> useradd; | |
cout << "Please enter password: "; | |
cin >> passwordadd; | |
cout << endl; | |
cout << "adding new record:\n"; | |
cout << nameadd << " " << useradd << " " << passwordadd << endl; | |
myfile << nameadd << " " << useradd << " " << passwordadd << endl; | |
if (myfile.fail()) | |
cout << "Failed adding data \n"; | |
else | |
cout << "data added! \n"; | |
} | |
} | |
else | |
{ | |
cout << "Please login. Enter name<space>password: "; | |
cin >> user1 >> password1; | |
ifstream file("personal.txt"); | |
string line; | |
while (getline(file, line)) | |
{ | |
if (user1 == user && password1 == password) | |
cout << "Welcome!"; | |
else | |
cout << "You failed!"; | |
} | |
} | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment