Wednesday, October 1, 2008

Code for Random Number Generator

This is something I always thought of doing but it was always a priority 2 task for me. Today when I was in a fix of keying in make and make install each time I had to run my test I finally replaced the libuuid patch with a simple 3 line code of this random number generator function.

int temp_id=0;

void myRandomNumber()
{
unsigned int myseed;
myseed = (unsigned)time(NULL);
srand(myseed); // Initialize the random number generator
temp_id = rand(); // Random number
}



Reference:
http://www.randombots.com/random_control.htm


Vaibhav

No comments: