How to generate a list of alphanumeric random passwords from a given length n? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to generate a list of alphanumeric random passwords from a given length n?

https://code.sololearn.com/cnrk13r4aOI7/?ref=app So from what I observed from this code made by @SoloLearn, I find that it only gives one random password but “not” a list. I thought that ok, maybe I could use my knowledge about loops to generate a list of passwords but there is always a problem when I do things such that the while iterations only output one alpha-numeric each. This bothers me since I can’t any longer proceed anywhere can someone give me an idea on how to deal with password generator?

14th Apr 2022, 2:51 AM
Sureta Darren
Sureta Darren - avatar
7 Answers
+ 2
Do you know the C++ language documentation website? https://www.cplusplus.com/reference/vector/vector/ There is a method called "push_back" to add strings to the vector. It also has an example application.
14th Apr 2022, 5:22 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
Subtask 1: Put the single password generator from Sololearn into a function that takes a parameter n and returns the password of length n as string. Subtask 2: Write a function that pushes k passwords of length n into a vector<string> with help of the function you wrote in subtask 1. Subtask 3: Write a main method that takes n and k as user input and call the function you wrote in subtask 2. Focus on one subtask at a time. Learn about the tools necessary to complete them (string, stringstream, vector, loops, ...).
14th Apr 2022, 4:13 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
This is plausible Subtask 1, is easy to do. But the rest I don’t know how to continue
14th Apr 2022, 5:11 AM
Sureta Darren
Sureta Darren - avatar
+ 1
Where exactly is the problem? The vector, the loop, or taking input?
14th Apr 2022, 5:19 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
This is great, thank you. I’m reading a book called C++ by Richard Grimes I don’t know any other resource like the one you presented. It’s common sense but I’m too silly to know
14th Apr 2022, 5:28 AM
Sureta Darren
Sureta Darren - avatar
+ 1
😄 Well, you're very welcome 🙂 And good luck 🍀 Should you run into any further trouble, don't hesitate to ask.
14th Apr 2022, 5:34 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
The vector
14th Apr 2022, 5:19 AM
Sureta Darren
Sureta Darren - avatar