We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,322 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

srandom

what does time(NULL) and srandom(time(NULL)) do in c ?

4
Contributors
3
Replies
8 Hours
Discussion Span
9 Months Ago
Last Updated
4
Views
Related Article: Float Point Excepting w/Code is a C discussion thread by Detkimble that has 2 replies and was last updated 1 year ago.
maurya10
Newbie Poster
18 posts since Nov 2011
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 0

What part of Computer Science your question is, looks like you posted C code here? I transfer your post to correct forum.

pyTony
pyMod
Moderator
6,312 posts since Apr 2010
Reputation Points: 879
Solved Threads: 987
Skill Endorsements: 26

time gives the time in seconds. Feeding that to srandom seeds the pseudo random number generator based on the time of day.

L7Sqr
Practically a Posting Shark
851 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

<pedantic>
Not time of day, number of seconds since the epoch passed so you get a different seed every time (as long as you don't manage to seed your PRNG twice with-in 1 second).
</pedantic>

Banfa
Practically a Master Poster
695 posts since Mar 2010
Reputation Points: 508
Solved Threads: 109
Skill Endorsements: 5

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0471 seconds using 2.49MB