Password Generator | Sololearn: Learn to code for FREE!

+3

Password Generator

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

Dawid

8 Answers

New Answer

+4

There 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

+5

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

+2

Thank you again!

+1

Wow thank you!

+1

Fixed it, but there is still one tiny error in the switch statement. Mind taking a quick look?

+1

I guess you want something like this https://code.sololearn.com/chkalVvSgT6Y/?ref=app

+1

very efficient, I like the version!

+1

https://code.sololearn.com/czvRpK1TEItY/?ref=app Click the above link and get your require code☺