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;
        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.

Edited 3 Years Ago by Reverend Jim: Fixed formatting

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;

Edited 6 Years Ago by chiwawa10: n/a

This question has already been answered. Start a new discussion instead.