|Apr 10, 2008, 12:31 AM||#1|
I'm making a program that needs to produce a different random number each time the program is used, the problem is when I use the random() function, it produces the same random number each time I use it.
|Apr 10, 2008, 12:39 AM||#3|
You need to seed your program with srandom(unsigned long seed), if you use the same seed in 2 different runs you will get the same result every time, which is useful for debugging. Once you want to deploy your application you can use the computer time as the seed and this will produce different seed every time.
Systems: MBP SantaRosa, 15', 160Gb@7200 rpm HD; G4 mac mini
iPod: ipod nano 1Gb, 1st gen, touch 16 Gb, 2nd gen
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Random Resets||jlhx||iOS 7||8||Dec 1, 2013 08:43 AM|
|Random Apple ID||kousha||OS X Mavericks (10.9)||2||Nov 19, 2013 11:21 AM|
|iPhone: Random Crashing||cclloyd||Jailbreaks and iOS Hacks||5||Feb 8, 2013 01:26 PM|
|MBP 2010 random/not so random crashes?||Kobaine||MacBook Pro||0||Jan 3, 2013 05:10 PM|
|Random sleep||Chrisspy||MacBook Pro||0||Nov 27, 2012 11:19 AM|
All times are GMT -5. The time now is 10:44 PM.