True Random Function in C

Status
Not open for further replies.

T1junkie

In Runtime
Messages
303
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.
 
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.
 
there is no absolutely true random function in any language, don't you think so?
 
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
 
Status
Not open for further replies.
Back
Top Bottom