-
Random function
I made this function just to make the use of random numbers easier in my programs. For some reason the compiler doesn't like it. The error is "void value not ignored as it ought to be".
Code:
int random(int range){
int r;
r=srand((unsigned)time(NULL))%range;
return r;
}
I have a feeling it is something stupid but I did check this time to make sure that I had the right return thing declared in the beginning. what's wrong???
~Sven
-
srand returns void, and is ONLY used for seeding the random number generator. use rand to get a random number, and only call srand once durring the execution of your program.
-
Oops forgot about that. Thanks!
~Sven