Mail Archives: djgpp/1997/02/02/13:30:38
If you only call it once without setting the seed, the rand function
returns 0 on the first call. However, if you call it in a loop, say 10
times, you will see the value change. Since the rand function is
deterministic, the same values will always appear. Other than that, I see
no reason why you should always get 0 or 1.
Chester
On Sun, 02 Feb 1997 00:04:25 -0800, Terence Ramos <de-bug AT ix DOT netcom DOT com>
wrote:
>Hello...
>
>I have been having trouble to get DJGPP to give me random numbers. I am
>using the function rand()... this is how my source looks like
>
>number = rand() % 100 + 1;
>
>that should give me a random number from 1 to 100 right? well i keep on
>getting the same number which is 1. So i took out the + 1 part and now
>i only get 0. whats wrong here? Any help would be appreciated...
>
>[Terence Ramos ]
>[de-bug AT ix DOT netcom DOT com]
- Raw text -