Mail Archives: djgpp/1997/03/04/22:43:20
Hi,
>Sorry for asking that stupid question, but can anybody tell me how i can
>get random numbers from 0 to 255?
>
>Do i have to call something like a randomize timer function like in
>Borland?
I use srand() and rand() instead of the randomize() stuff.
You might have to include proper files for srand(), rand() and time().
Do this:
srand(time(NULL));
x=rand() % 255;
Line 1) Initialize the seed using the system clock.
Line 2) Give variable x a random number between 0-255.
Bye!
****************************************************
* Gautam N. Lad *
*--------------------------------------------------*
* *
* E-Mail : gautam AT interlog DOT com *
* Website : http://www.interlog.com/~gautam *
* *
* OS/2, DOS/Windows, Graphics Gallery, Software, *
* Links, Rayzor Editor/2, POV-Ray, and more. *
****************************************************
- Raw text -