Click here to Skip to main content
15,911,531 members

Comments by TRPatil (Top 1 by date)

TRPatil 4-Oct-11 12:59pm View    
hmmm even I cant explain you the exact mechanism of this function..
but the problem with rand function is it will generate the same sequence whenever u execute it... and we need different nuber as the execution goes on... so we need to give some seed value for the random generator so that it will generate different no each time.
for that reason srand() is used ... we need to initialize the srand () function before we use it...
as we need different no we have to provide different seed value every time and time is the best option for this as it will never be same as the execution proceeds :) hence srand() is generally itialize with time(NULL) ..
u can find more help on srand() here
http://msdn.microsoft.com/en-us/library/f0d4wb4t%28v=vs.71%29.aspx