On Sat, Jun 26, 2010 at 1:52 AM, kumar anurag <[email protected]> wrote:
>
> HERE is another using <time.h> file
> its sequence will always be unique
>
> #include<time.h>
> #include<stdio.h>
> int main()
> {
>  time_t t;
>
>  int i;
>
>  srand(time(&t));
>  i=rand()%1000;
> printf("%d",i);
> return 0;
> }

The sequence will not always be unique is the point I tried to make
earlier. If you look at the man page of time(), it says that time is
returned in seconds. That means, if you launch your program twice
within the same second (and it is not far fetched), you will NOT get a
pseudo-unique random sequence.


SB

-- 
l...@iitd - http://tinyurl.com/ycueutm

Reply via email to