The first part inside the "If" statement works perfectly. The only part I am having trouble with is the "else" statement. I was trying to get it to generate an "x" amount of passwords and get those passwords to be at a length defined by the user. The problem is that it will only spew out one password. The rest have the "Password(x): " but nothing beside it. I have been through the code I don't know how many times. Would someone be able to help me? I'd greatly appreciate it. Thank you
#include <iostream>
#include <ctime>
using namespace std;
int main () {
int amount, length;
cout << "Password Generator v1" << endl;
cout << "How many passwords would you like to generate?" << endl;
cin >> amount;
cout << "How long would you like the passwords to be?" << endl;
cin >> length;
cout << endl;
cout << endl;
srand( time(NULL) );
if (amount == 1) {
cout << "Your generated password is: ";
while (length > 0) {
cout << (rand() % 9) + 1;
length--;
}
}
else {
cout << "**Passwords List**" << endl;
cout << endl;
for (int r = 0; r <= amount; r++) {
cout << "Generated password(" << r << "): ";
//Creates password length
while (length > 0) {
cout << (rand() % 9) + 1;
length--;
}
// Adds spacing after each password
cout << endl;
cout << endl;
}
}
cout << endl;
system("pause");
return 0;
}