Hi all,

I need to get a random number from the following:

#define RAND(min,max) ((min)+(int)((double)(max-min+1)*rand()/(RAND_MAX+1.0)))

but when I print it out it just prints the value of min.

printf("%d", RAND(10000000,99999999));

please help!
thanks in advance.

Defines are just stupid "find and replace" substitutions, made before the program starts, and that can lead to a LOT of problems that are hard to de-bug.

A small function seems perfect for this.

Thanks for your reply but I solved the problem.
turns out you have to change the the seed with which the pseudo-random generator is initialized.
Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.