Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 01-27-2004, 08:38 AM   #1 (permalink)
 
Super Techie

Join Date: Dec 2003

Posts: 302

T1junkie

Send a message via AIM to T1junkie
Default True Random Function in C

does anybody know a true random function for C/C++
the only one I have seem is the Psuedo random function which has no use to me.
__________________
IBM/Lenovo T43 2687DSU
Pentium M 2.0Ghz
1024 MB (DDR2 SDRAM)
80 GB Ultra ATA, 5400 RPM
14.1\" LCD
Windows XP Pro
DVD-R
64MB ATI MOBILITY RADEON X300
Integrated 802.11A/B/G, Bluetooth, 10/100/1000 Eth.
T1junkie is offline  
Old 02-15-2004, 11:43 AM   #2 (permalink)
 
Newb Techie

Join Date: Feb 2004

Posts: 6

cdecarlo

Default

Hey,

You can use int rand(unsigned_int *seed) to create a psuedo random number that won't spit out the same numbers all the time. A good way to use it might be

int x = 0;
x = rand(&x);

make sure to include stdlib.h

if you really need more random than that there is void srand(unsigned_int seed) that will reseed your random number generator then use int rand(void) to pop out a new number. example

int currentTime = (the current time, sorry i forget);
int randomNumber = -1;
srand(currentTime);
randomNumber = rand();

hope it helps.
cdecarlo is offline  
Old 02-19-2004, 12:08 PM   #3 (permalink)
 
Newb Techie

Join Date: Feb 2004

Posts: 11

sunl

Default

there is no absolutely true random function in any language, don't you think so?
sunl is offline  
Old 02-19-2004, 05:08 PM   #4 (permalink)
 
Super Techie

Join Date: Dec 2003

Posts: 302

T1junkie

Send a message via AIM to T1junkie
Default

I realize that there is no Completly true Random function
but I need one that can turn out random numbers every 1/10 of a second
__________________
IBM/Lenovo T43 2687DSU
Pentium M 2.0Ghz
1024 MB (DDR2 SDRAM)
80 GB Ultra ATA, 5400 RPM
14.1\" LCD
Windows XP Pro
DVD-R
64MB ATI MOBILITY RADEON X300
Integrated 802.11A/B/G, Bluetooth, 10/100/1000 Eth.
T1junkie is offline  
Old 02-21-2004, 10:09 PM   #5 (permalink)
 
Newb Techie

Join Date: Feb 2004

Posts: 6

cdecarlo

Default

Are you using my suggestion, that should do the trick.
cdecarlo is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On