# Random numbers in array

Hello, i'm working on my project, but i have a little problem, i want to generate random arrays, which include 4 numbers randomly from 0 to 9 i have this code:

``````int heslo1 = 0;
int heslo2 = 0;
int heslo3 = 0;
int heslo4 = 0;
char Main = {heslo1, heslo2, heslo3, heslo4}; //activation password

void loop(){
heslo1 = random(0,9); // first digit of generated password
heslo2 = random(0,9); //
heslo3 = random(0,9); //
heslo4 = random(0,9); //
}
``````

but when i enter new code, that is displayed on display it's wrong, i have idea, the problem is in "char Main = {heslo1, heslo2, heslo3, heslo4}; //activation password " because everything works if i change this line like this: Main = {'1', '2', '3', '4'}; but i don't have idea what problem it is :)

1 != '1'

Also, for "random", the upper limit is exclusive, so if you want 0..9, you need "random(0,10);" http://arduino.cc/en/Reference/Random

``````char Main = {heslo1, heslo2, heslo3, heslo4}; //activation password
``````

the heslo values are only copied so your array is equivalent to

``````char Main = {0, 0, 0, 0}; //activation password
``````

do you mean

``````int heslo1 = random(0,9);
int heslo2 = random(0,9);
int heslo3 = random(0,9);
int heslo4 = random(0,9);
char Main = {heslo1, heslo2, heslo3, heslo4}; //activation password
``````

EDIT: and like AWOL said, maybe even

``````int heslo1 = '0' + random(0,9);
int heslo2 = '0' + random(0,9);
int heslo3 = '0' + random(0,9);
int heslo4 = '0' + random(0,9);
``````

You probably do NOT want to reassign those values in loop(), either.