Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- // Open userDB.dat for input
- ifstream inUserDB("C:/userDB.dat");
- // Open userDB.dat for output, and app (append) will add new text without removing the old
- ofstream outUserDB("C:/userDB.dat", ios_base::app);
- string checkUser;
- string userIn;
- string passIn;
- string newUser;
- string newPass;
- cout << "Username: ";
- cin >> userIn;
- cout << "Password: ";
- cin >> passIn;
- inUserDB >> checkUser; // converts the text in userDB.dat to the string
- if (userIn != checkUser || passIn != checkUser) // if what the user inputted does not match the database
- {
- cout << "LOGIN FAILED.";
- }
- else
- {
- cout << "Welcome " << userIn;
- cout << "\nPlease enter the username you would like to add to the database: ";
- cin >> newUser;
- cout << "Please enter a password to be added to the new username: ";
- cin >> newPass;
- outUserDB << "\n\n" << newUser << "\n" << newPass; // Adds the new user/pass to the database
- system("PAUSE");
- }
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement