:confused: Arrgh!!! Cant understand these sentence from this website of brickos programming:
http://legos.sourceforge.net/HOWTO/x600.html
random() and srandom(int x) are now available in legOS. To use them, just call srandom(int x) at some point during your program startup. x is a "seed", which allows you to get the same sequence of numbers if you so desire (by passing the same seed) or to generate more truly "random" numbers by feeding in, for example, LIGHT_1. Be aware: unlike the "standard" implementation of these two functions, there is no "default" seed, so if you don't call srandom() at least once, random() will return the same number over and over again.
source code:
//! generate a random number
/*! The random() function returns successive pseudo-random numbers
* \return a random number in the range from 0 to RAND_MAX
*/
extern long int random(void);
//! seed the random number generator
/*! The srandom() function sets its argument as the seed for a new sequence
* of pseudo-random integers to be returned by random(). These sequences
* are repeatable by calling srandom() with the same seed value. If no
* seed value is provided, the random() function is automatically seeded
* with a value of 1.
* \param seed
* \return Nothing
*/
extern void srandom(unsigned int seed);
I have try:
void main{
srandom(int x);
long int k = random();
}
void main{
int x = 27;
void srandom(x);
random();
}
void main{
random();
k = srandom(27);}
and many many possibilities... but still the compilation error comes out:
Internal compiler error.
Please submit a full bug report.
Can anyone help me up?
how can i achieve to have the program to randomly choose a number from 0 - 27?
Head really wanna explode!!!
Thanks.