Random Generator

Discussion around programming R'n'D, its source code and its tools.

Moderators: Flumminator, Zomis

Post Reply
richard
Posts: 199
Joined: Fri Jun 18, 2004 9:00 pm

Random Generator

Post by richard »

I am starting to program C++ and I need some help.

I wanted to create a random number minimum and maximum.
So I need a wildly random generating function: that one time based.

Code: Select all

srand( (unsigned)time( NULL ) );
But how can I bring the random number that is over 100000 to 0-1 ?

I tried:

Code: Select all

int R=(rand()%2);
But in the result it brought me only the minimum OR the maximum, and nothing between them. Maybe somebody could tell me please how I could do that ? Thanks.

*EDIT*

Or yes... or do you know an another way to make a random number 0-1 ?

And yes... my beginner program here: http://s8.invisionfree.com/rocksndiamon ... &id=621544
Last edited by richard on Sun Jun 20, 2004 12:30 pm, edited 1 time in total.
richard
Posts: 199
Joined: Fri Jun 18, 2004 9:00 pm

Post by richard »

Juhuu !

It works now as it should ! :D
Aynways... I will upgrade it, and try to make a interface and such stuffs.
Post Reply