The function rand()
doesn't return random numbers. It's a pseudo random generator instead. That's why you get the same sequence of numbers when you call srand()
with the same argument. Calling srand()
with the current time is the actually only random item. The numbers you get from rand()
are just scrambled.
You will call srand()
with a predictable or constant value when you want to replay
a sequence, debug a functionality with the same sequence again and again.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…