Hello gang, I’m trying to make a random password generator. My syntax kinda explains my thought process: Create a huge string with all the characters needed, make a loop which randomly selects characters from it until it has reached 8 characters. But of course it doesn’t work the way I want it to. Any help would be appreciated. https://code.sololearn.com/ciL83fB4DS45/?ref=app
1/19/2019 10:10:12 PM
Dawid8 Answers
New AnswerThere are several errors in the code. You don't need to prototype main() inside it. And since you need to output "Your PW:" only once, put it outside of the loop. Here's a fixed one. Try to compare this with your code to understand it better. https://code.sololearn.com/cWwsT4DaOM61/?ref=app
This is what you should do in line 21: std::cout<< str[rand()%str.length()]; srand() is used for seeding the rand() function. You should use rand() instead of srand(). rand() doesn't accept parameters. https://code.sololearn.com/cBJ8H15dLL8k/?ref=app
Fixed it, but there is still one tiny error in the switch statement. Mind taking a quick look?
https://code.sololearn.com/czvRpK1TEItY/?ref=app Click the above link and get your require code☺
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message