Hey all! Teaching myself C and I'm trying to understand how random numbers work...
I'm trying to make a simple function to generate a single random integer (<= maxnum) that is different every time its called.
Everybody i've asked so far has sent me through pages and pages of information on pseudo-random numbers which my young brain just cant quite handle yet.
I've been told to use srand(time(NULL)) to seed, but does that not just use the same number every time? Due to 'time(NULL)' being the system time when the program was RUN?
Code:
int getrandnum(int maxnum)
{
srand(time(NULL));
return rand() % maxnum + 1;
}
Any help much appreciated!