Got a task to do password generator.
Right now i have a problem with the output because if i build the code
so my problem is that i need to get something more like this with my own input choice and to mix it into each other so it wouldn't go like the first picture.
i hopefully made myself more clear about my problem.
i - stands for the number for cycle.
la - stands for the lower alphabet for cycle.
ha - stands for the higher alphabet for cycle.
#include <iostream>
#include<ctime>
using namespace std;
const char num[] = "0123456789";
const char lower_alp[] = "abcdefghijklmnopqrstuvwxyz";
const char higher_alp[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int sizeofnum = sizeof(num) - 1;
int sizeoflower_alp = sizeof(lower_alp) - 1;
int sizeofhigher_alp = sizeof(higher_alp) - 1;
int main()
{
int password_length = 0, nums, loweralp, higheralp;
cout << "Enter password length: ";
cin >> password_length;
cout << "How many lower alphabet symbols do you want in the password:";
cin >> loweralp;
cout << "How many higher alphabet symbols do you want in the password:";
cin >> higheralp;
cout << "How many numbers do you want in the password:";
cin >> nums;
srand(time(NULL));
for (int i = 0; i < nums; i++) {
cout << num[rand() % sizeofnum];
}
for (char la = 0; la < loweralp; la++) {
cout << lower_alp[rand() % sizeoflower_alp];
}
for (char ha = 0; ha < higheralp; ha++) {
cout << higher_alp[rand() % sizeofhigher_alp];
}
return 0;
}