hi , i just want to ask the use of time and NULL here .......
and also , are the random numbers generated this way really random ????
hi , i just want to ask the use of time and NULL here .......
and also , are the random numbers generated this way really random ????
>>hi , i just want to ask the use of time and NULL here .......
Read this.
>>are the random numbers generated this way really random ????
No.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
It seeds the random number generator with the current system time. This only needs to be done the once.
You then use rand() to get random numbers. They are reasonably random,not perfect but computers can only do as they are told to and cannot just think of a number for themselves so they will never produce truly random numbers.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
The NULL means that the value (the time in seconds) isn't stored anywhere.Code:/* Seed the random-number generator with current time so that * the numbers will be different every time we run. */ srand( (unsigned)time( NULL ) );
>>are the random numbers generated this way really random ????
The numbers generated are known as pseudo-random numbers.
i recall a linux module whose purpose was to support entropy-randomness collection from a chip on the motherboard... maybe it's a specialized-applicaitons thing