proof c++ hates me my random number generator generates the same number

the identical program can be found on uncle buckys web video on random numbers http://www.youtube.com/watch?v=naXUIEAIt4U&feature=edu&list=PLAE85DE8440AA6B83

and see how mine is EXACTLY the same...jsut different results

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;



int main ()
{

for (int a=0;a<10;a++)
{
srand(time(0));
cout<<1+(rand()%6)<<endl;
}

}
Last edited on
Seeding the random number needs to come before the for loop (just as it is in the tutorial you linked - check 8:12 in the video.)
Last edited on
ooh yeah sry , so much for exactly the same
Topic archived. No new replies allowed.