RAND_MAX: how do i set?
i have made a program in school that chooses a random number and you need to guess it. you put in a number and it says higher or lower.
the only problem is that i can't set RAND_MAX and its a 4 or 5 diget number (havent figured it out yet). the help explains RAND_MAX but doesn't say how to set it.
plz help
thnx
a confused yr 9
humbug
P.S.do you need to refresh the page to see replys?
humbug
Junior Poster in Training
93 posts since Oct 2005
Reputation Points: 20
Solved Threads: 13
You don't set RAND_MAX, it's a constant value (usually 32767). I don't see why you would want to set it unless the range is too small for you (in which case you use a better random number generator). Tell us how you're trying to go about solving the problem, show us your code, and we'll help you with it.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
thanks
the code is at school and i cant remember exactly how its writen so ill get it from school later. (probably tomorow or the next day)
im using srand((????)time(NULL)) (coppied from the example).
byt the way, why douse RAND_MAX exist if it cant be set? is there another reason?
i saw the other way of making a random nunber but it looked cofusing so stuck with the other method.
humbug
Junior Poster in Training
93 posts since Oct 2005
Reputation Points: 20
Solved Threads: 13
byt the way, why douse RAND_MAX exist if it cant be set? is there another reason?
RAND_MAX doesn't 'exist', for some definitions of the word. It just happens to be a fact that rand() will return a value that is less than or equal to whatever value RAND_MAX denotes. It's not a variable in memory; it gets replaced with a regular old number by the compiler. For example, my compiler replaces it with the value 2147483647. The value you get depends on the random number generator your version of rand() uses.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177