0
Pass. Generator
https://code.sololearn.com/c92LAB271F9c/?ref=app i wrote this but it is not giving me any output is there a problem with the codes? please help
4 odpowiedzi
+ 2
You are writing to memory that wasn't properly allocated to the string yet. You need to resize the string like so:
string password;
int length = 5;
password.resize(length);
Or you can add to the string instead:
password += ascii_char;
+ 2
@Mustafa K.
Yes, you surely can.
Assume lower end of range as L and upper range as U. Then, the formula with rand() is:
int x = L + ( rand()%(U-L+1) );
Eg -
int x = 15+rand()%6;
// Returns number between 15 and 20.
+ 1
Not sure, but I think you can't use "password[i]", you can i.e. use "password += ascii_char" or a string function "add" if i'm correct. Also there's no need for a "for" loop with "j".
+ 1
thnks for answers, i want one more thing, can i produce random number between x and y ?