Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
RE: [C help] how to...
code:int <result> = rand() % <out-of>;
The rand() function returns a number from 0 to MAX_INT (32,767 I think). By using the modulo division operator %, you can replace <out-of> with an integer e.g. use 10 to get a random number from 0-9 inclusive.