For a textfile that has usernames and passwords with end being the sentinel
user1 password1 user2 password2 end
How do I add user and password to a vector? I am trying to keep the same user and password combination but only have
ifstream fin;
fin.open("users1.txt");
while(fin != "end"){
user_list.push_back(user_l);
}
for vector
vector<User> user_list;
edit:
user1 password1
user2 password2
end
edit 2:
#include "BBoard.h"
#include <fstream>
using namespace std;
User user_l;
BBoard::BBoard(){
title = "Hello World";
vector<User> user_list;
User current_user;
vector<Message> message_list;
}
BBoard::BBoard(const string &ttl){
title = ttl;
}
void BBoard::setup(const string &input_file){
ifstream fin;
fin.open("users1.txt");
while(!fin.eof()){
user_list.push_back(user_l);
}
}
header
#ifndef BBOARD_H
#define BBOARD_H
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class User{
};
class Message{
};
class BBoard{
private:
string title;
vector<User> user_list;
User current_user;
vector<Message> message_list;
public:
BBoard();
BBoard(const string &ttl);
void setup(const string &input_file);
void login();
void run();
private:
//void add_user(istream &infile, const string &name, const string &pass);
bool user_exists(const string &name, const string &pass) const;
//User get_user(const string &name) const;
//void display() const;
//void add_message();
};
#endif