+ 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?
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.
+ 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, ...).
+ 1
This is plausible Subtask 1, is easy to do. But the rest I donāt know how to continue
+ 1
Where exactly is the problem? The vector, the loop, or taking input?
+ 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
+ 1
š Well, you're very welcome š And good luck š Should you run into any further trouble, don't hesitate to ask.
0
The vector