Hello, I need help on writing a C++ program that allow the user to input two values: a username and a password. Below is what I have so far to test the password and it is not working.

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main ()
{
    string username, password, login;

    cout << "\n";
    cout << "            --------------- Username & Password ---------------\n";
    cout << "\n";

    vector <string> v;
    cout << " Enter a Username (or 0 to stop).\n\n";

    getline(cin, username); 
    while (username != "0")
    {
                  password = "abc123";
        login = username + password;
        v.push_back(login);
        getline(cin, username);
    }
    cout << "\n";
    return 0;
}

I have the username working now I just need to get the password working.  Any suggestions is greatly appreciated.

if you are asking how to ask for a password then just ask for it inside the while loop. Replace password = "abc123"; with code to ask the user for there password and then retrieve the password.

You could code it this way to request user to enter password

cout << "Enter password for user: " << username << endl;
cin >> password;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.