The program I created is suppose to work as follows.
Program takes an array with predetermined values on it (in this case it takes the values of a deck of cards).
The program then randomly pulls a value from the array (to simulate someone pulling a card from a deck of cards).
The program then is suppose to take that value and put it into a different array as a single value.
And this is sort of what my program is doing. However, it only does this if I run it in the debugger. If I just let it run regularly the resulting array simply just repeats the first random value.
//Random number generator
srand(time(0));
m = rand() % 3;
srand(time(0));
n = rand() % 12;
// pick a card any card
*card = cardDeck[m][n];
}
void randomGenerator(int *randomnum)
{
//random number generator that gives the dealer a sense of unpredicablity.
int a = 0;
srand(time(0));
a = rand() % 5;
*randomnum = a;
You should only call srand once in your program. At the beginning of main is a good place.
The reason for this is because srand is only used to initialize the random sequence you get from rand(). If you use the same seed you will get the same sequence of numbers from rand(). In your program you use srand(time(0)) before each call to rand(). time(0) returns the time in seconds so it is very likely that you will get the same number each time, which means you also will get the same number from rand().
I see you have failed to use the [code] tag. You are supposed to place your code between [code] and [/code]. Not between [ and ].