Michael said:
The standard C functions do not have arguments for a range of values.
You can however easily create a function to do this:
int myRand(int min, int max)
{
srand(time(0));
return (rand()%(max-min))+min;
}
To the OP:
This works, but don't do copy/paste this into your code. In your code,
be sure to call srand(time(0)) somewhere else (top of main() is good)
or every single call to myRand() in the same clock second will return
the same random number.
And in case you weren't already aware, you'll also need to #include
<time.h> and <stdlib.h> to have the time(), rand(), and srand()
functions prototyped.