How to save multiple values.

I'm stuck on my final project hurdle. The void abc() generates a random number, that number is saved as randNumber. In my void loop, when ever digital.read(9) is high, it will call the abc() function, so a random number is generated everytime digital.read(9) is high. I need to record the values of randNumber everytime the abc() function is called. I need to save these values because im generating security codes so when I enter one of these randNumber/generated security codes on serial monitor or keypad then success.

void abc()
{

randomSeed(analogRead(0));
randNumber = random(6100,8100);

///then save randNumber value///

}

void loop()
{

if(digitalRead(9)==HIGH)
{
abc();
}

else
{
something else...
}

}

What do YOU mean by save? As in, put the result in a variable, or as in save across shutdowns?

By the way, I think that you want to call the function abc() when pin 9 BECOMES high, not when pin 9 IS high. The Arduino IDE has an example that demonstrates how to do this.

Write the values to an array.
If the function were not a void function, you could do that directly

TheMemberFormerlyKnownAsAWOL:
Write the values to an array.
If the function were not a void function, you could do that directly

Thanks for your reply, this was my inicial idea, However it is a bit complicating for me. Something like the code below, but the problem is that my randNumber is always going to be saved to (a), I need it to save a first time, then randNumber = b second time, then randNumber = c... so on so on...

void loop()
{
int a;
int b;
int c;
int d;
int exitCodes[] = { a, b, c, d};
const int nElements = sizeof(exitCodes) / sizeof(exitCodes[0]);
int z = a;

if(digitalRead(9)==HIGH)
{

randomSeed(analogRead(0));
randNumber = random(6100,8100);
randNumber = a; ///here the random number generated is stored in (a) of the array...//
///problem here is that it will always save as a//
}

else
{
something else...
}

for( int idx=0; idx < nElements; idx++)
{

if ( exitCodes[idx] == z )
{
Serial.println("Success");

}

}
}

int z = a;At this point, the value of a is undefined.

Please remember to use code tags when posting code

Oh ok my bad. Ok assume int z = a is just above the for loop. This code is just for an example, its not my exact project code, my real code is too long (this code i used it just to make your life eaiser). But I just need an example how I can save the first generated randNum value as a, then second time round as b so on and so on.

int abc()
{

  randomSeed(analogRead(0));
  rerurn random(6100,8100);
}

Ringing any bells?