I am using C++ 2012. I want to use a rand() in program that must generate random values many times (100 random number for 3000 iteration) and all of these process should be done in a second or even fewer. How can i do this. I know that "srand((unsigned int)time(NULL));" must be used as a seed for rand(). But What about these tiny bit of time while the second in time() may be the same in all 3000 iteration. I know there exist "random.h" but I am a beginner and do not know how to use it. please help.
            Asked
            
        
        
            Active
            
        
            Viewed 89 times
        
    1 Answers
0
            Only seed your random number generator once.
srand() is used to seed the C library's random number generator (rand()). You absolutely do not want to call srand repeatedly, otherwise you ruin the psuedo-random properties of the RNG.
 
    
    
        Community
        
- 1
- 1
 
    
    
        Jonathon Reinhart
        
- 132,704
- 33
- 254
- 328
