Let's say I have an empty array of size 8.
int A[8];
And so I intend to populate it with random values whose I would have a function similar to rand();
However, I call rand()
for each element of the array, so all elements have the same value.
So far I have this function:
int randInt(int intMax)
{
srand(time(NULL));
return rand() % (intMax+1);
}
In case it would return the same value if I called this function two or more times, because it is related to time. My question would be how can I implement a function that returns a random value even by calling it two or more times?