View Single Post
Re: srand() aberration ???
Old
  (#3)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: srand() aberration ??? - 14-06-2004

heh weird stuff I tried this:
Code:
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 
 void main (void)
 {
    srand (time (NULL)); // initialize random seed
 
    // generate a pseudo-random number ranging from 0 to 99
    for (int i=0;i<15;i++)
 	   printf ("%d\n", (int) (100.0f * (float) rand () / float((RAND_MAX + 1.0f))));
 
    system("pause");
 }
and the first number was ALWAYS the same, the other numbers where random though.
  
Reply With Quote