|
-
Sep 22nd, 2001, 06:08 PM
#1
Thread Starter
Fanatic Member
Random Number in a specified range
I know how to get a random number using the time as a seed, but how can i have it be between two speficied numbers? (say, 65 to 90)
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 22nd, 2001, 09:33 PM
#2
You want random capital letters... chars from 65 to to 90....
Try:
PHP Code:
unsigned char r=0;
while (r<65){
r = rand() % 91;
}
printf("%c \n" , r);
-
Sep 22nd, 2001, 10:20 PM
#3
Thread Starter
Fanatic Member
Lol, so you saw that Thanks for the help.
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 22nd, 2001, 10:40 PM
#4
Thread Starter
Fanatic Member
Is it possible to have multiple ranges? ( I am trying to get any alphanumeric character)
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 22nd, 2001, 10:40 PM
#5
Code:
r = rand() % (max - min) + min
Z.
-
Sep 22nd, 2001, 11:16 PM
#6
Thread Starter
Fanatic Member
Thanks, that helps a lot.
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|