Question: why do i keep getting errors in c + + code when using getline? #include #include / / / / / / / / /

why do i keep getting errors in c++ code when using getline?
#include
#include
///////////////// Task 1: ///////////////////////////////
#include // fstream library
#include //sstream library for istringstream function
#include
using namespace std;
// Function prototype
bool userAuthentication();
void getCredentials(const string prompt, string &data);
int main()
{
// Check if the user is authorized
if (userAuthentication())
{
cout << "User is authenticated." << endl;
}
else
{
cout << "Authentication failed." << endl;
}
return 0;
}
/*
* Input: None
* Purpose: This function authenticates a user
* Output: true or false (bool)
*/
// Task2: define the function
bool userAuthentication()
{
///////////////// Task 2a: ///////////////////////////////
string line;
string tempUserName;
string tempPassword;
string userName; //declare userName
string password; //declare pw
///////////////// Task 2b: ///////////////////////////////
getCredentials("What is the UserName:", userName); //call function userName
getCredentials("What is your password:", password); //call funtion password
// Task #3///
///////////////// Task 3a: ///////////////////////////////
ifstream adminFile ("credentials.txt");
///////////////// Task 3b: ///////////////////////////////
adminFile.open("credentials.txt");
// Check if the adminFile opened successfully.
if (!adminFile.is_open())
{
cout << "System error in authentication. "<< endl;
return false;
}
else
{
///////////////// Task 3c: ///////////////////////////////)
while (getLine(adminFile, line)){
cout <<"**Showing the content of the file **."<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!