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

9th Jan 2018, 5:12 PM
Mustafa K.
Mustafa K. - avatar
4 Respostas
+ 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;
9th Jan 2018, 5:32 PM
aklex
aklex - avatar
+ 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.
9th Jan 2018, 5:47 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 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".
9th Jan 2018, 5:33 PM
rafal
+ 1
thnks for answers, i want one more thing, can i produce random number between x and y ?
9th Jan 2018, 5:41 PM
Mustafa K.
Mustafa K. - avatar