Username and password

This code is wrong in somewhere.Can you help me find out, how to display of any account that i just enter, i just complete in 2 of case , help me in case 2, pls :)

# include <iostream>
using namespace std;
void showdata(string&, string&, int);
int main(){
const int size=20;

string username;
string password;


int choice;
int count=0;
while(choice < 5){
cout << "\t\t PASSWOORD and USERNAME Menu\n\n";
cout << "1. InPUT Data\n";
cout << "2. Display Data\n";
cout << "3. Login\n";
cout << "4. Change PASSWORD\n\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
cout << " \t\t--------- INPUT-----------\n\n";
cout << " Enter -1 if you want to quit .\n";
// cin >> n
cout << " Enter accounts.\n";
//while (username != "-1"){
//cout << " Username: ";
for(int i=0; i < size; i++){
cout << " Username: ";
cin >> username;
if (username=="-1")
break;
cout << " Password: ";
cin >> password;
count++;
}
break;
case 2:
cout << " \t\t-----------Display----------\n\n";
cout << " This is list of your accout ";
// if(username!="1"){
count = size;
for(int a=0; a< count-2; a++){
cout << username << " - " << password;
//}
}
break;
}
}
return 0;
}
@khech45

You need an array to hold the names and another to hold the password, NOT just a single variable.

And please use the code tags [ code]... your code.. [ /code] (minus the space after the '[') to make it easier to view and comment, on your code.
It would be easier if you create a struct and use a vector.
1
2
3
4
5
6
7
8
9
10
struct AccountInfo
{
  string username;
  string password;
};

int main()
{
  vector<AccountInfo> accounts;
}
Topic archived. No new replies allowed.