Computers and Technology

In this laboratory, we are going to maintain a username-password system by storing the usernames and passwords in a file. The file will consist of a single username and password per line with a space in between. 1. Begin by creating a class PasswordFile which has the following interface:
class PasswordFile
public:
PasswordFile(string filename); // opens the file and reads the names/passwords in the vectors user and password.
void addpw(string newuser, string newpassword); //this adds a new user/password to the vectors and writes the vectors to the file filename bool checkpw(string user, string passwd); // returns true if user exists and password matches
private:
string filename; // the file that contains password information
vector user; // the list of usernames
vector password; // the list of passwords
void synch(); writes the user/password vectors to the password file
The constructor accepts a filename, and reads the file one-line at a time and adds values to the vectors user and password. The function addpw adds a user/password pair to end of each vector.
2. Now create a password. txt file with some entries such as:
jsmith turtle
madams apple
Also create a main program to test your classes :
int main() PasswordFile passfile
("password. txt");
passfile. addpw("dbotting","123qwe");
passfile. addpw("egomez", "qwerty");
passfile. addpw("tongyu", "liberty");
// write some lines to see if passwords match users

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:30, jcazares3558
Awell-diversified portfolio needs about 20-25 stocks from different categories.
Answers: 2
image
Computers and Technology, 23.06.2019 12:30, legend101xD
Animations and transitions are added from the
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, LouieHBK
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe and
Answers: 1
image
Computers and Technology, 24.06.2019 07:00, sudotoxic
Into what form does the barcode reader convert individual bar patterns?
Answers: 1
Do you know the correct answer?
In this laboratory, we are going to maintain a username-password system by storing the usernames and...

Questions in other subjects:

Konu
Mathematics, 02.02.2020 15:52