Here you go.
Code:
#include <iostream>
#include <fstream>
#include <string>
int ScanFile(std::string UserName, std::string Password);
bool goodup;
int main()
{
std::string UserName, Password;
while (goodup != 1)
{
std::cout << "Please enter a username consisting of a first and last name, seperated by a single space: ";
std::getline(std::cin,UserName);
std::cout << "\nPlease enter your password: ";
std::cin >> Password;
ScanFile(UserName, Password);
}
std::cin.get();
return(0);
}
int ScanFile(std::string UserName, std::string Password)
{
std::string temp;
std::ifstream ifile("passwords.txt");
while (!ifile.eof())
{
std::getline(ifile, temp);
if (temp == UserName)
{
std::getline(ifile, temp);
if (temp == Password)
{
std::cout << "\nLogin successful.";
goodup = 1;
break;
}
else
{
std::cout << "\nBad password.\n\n";
break;
}
}
if (ifile.eof() && temp != UserName)
{
std::cout << "\nInvalid username.\n\n";
}
}
ifile.close();
std::cin.ignore(80, '\n');
return(0);
}