+ 2

Random elements from an array

I have a question. I'm trying to complete the password generator assignment and I don't know how to output a random element from an array. Can anyone help me? https://code.sololearn.com/chT9Fw0fw3Mr/?ref=app

16th Jan 2019, 11:27 AM
Diogo Pinto
Diogo Pinto - avatar
4 Answers
+ 2
https://en.cppreference.com/w/cpp/numeric/random/rand Hint: In your loop, generate a random number between 0 and the length of your char array, and use it to get a char from that array and print it.
16th Jan 2019, 12:55 PM
Zen
Zen - avatar
+ 3
Ok thanks! but I would like to output random letters.
16th Jan 2019, 12:25 PM
Diogo Pinto
Diogo Pinto - avatar
16th Jan 2019, 11:50 AM
KrOW
KrOW - avatar
+ 1
Thanks Zen
16th Jan 2019, 1:51 PM
Diogo Pinto
Diogo Pinto - avatar