Skip to content

Instantly share code, notes, and snippets.

Created August 5, 2014 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2514efea38a305d0ea66 to your computer and use it in GitHub Desktop.
Save anonymous/2514efea38a305d0ea66 to your computer and use it in GitHub Desktop.
#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