I got this code from the FAQ section... I've edited the values because I only need values from 1-6.
I don't understand how most of it works, especially the rand() and srand() functions, and the GetRand function. help?
int GetRand(int min, int max);
int i, r;
for (i = 0; i < 1; i++)
r = GetRand(1, 6);
printf ("Your number is %d\n", r);
int GetRand(int min, int max)
static int Init = 0;
if (Init == 0)
Init = 1;
rc = (rand() % (max - min + 1) + min);