I seem to be running into problem. I'm using a sort of random number generator (with of course, add stuff). I've found that every time I run my program, all ten of the numbers generated are the same. If I run the program again, the are ten different numbers, but still the same. (eg. the first time: 120 120 etc. second time, 653 653 653 etc..
here's the code I used to test this random feature:
roof is 999, and maxAmount is 10. randomGenerator should return a number from 2 to 1000 (which it does).
I got the randomGenerator of the internet.
Any help?
here's the code I used to test this random feature:
Code:
while (loopCounter<maxAmount)
{
number = randomGenerator(roof);
loopCounter += 1;
printf("%d has been generated.\n", number);
}
int randomGenerator(int max)
{
srand ( time(NULL) );
return (rand() % max + 2);
}
roof is 999, and maxAmount is 10. randomGenerator should return a number from 2 to 1000 (which it does).
I got the randomGenerator of the internet.
Any help?
Last edited by a moderator: