I'm trying to generate a random from 1 - 99,999,999 However, its not ever getting that high. I believe it has something to do with the size of an int.
Here is what I'm trying
(1 + rand() % 99999999)
Thanks
I'm trying to generate a random from 1 - 99,999,999 However, its not ever getting that high. I believe it has something to do with the size of an int.
Here is what I'm trying
(1 + rand() % 99999999)
Thanks
your code will not work because value returned by rand have a maximum value RAND_MAX
int rand (void);
Generate random number Returns a pseudo-random integral number in the range between 0 and RAND_MAX.
RAND_MAX
Maximum value returned by rand This macro expands to an integral constant expression whose value is the maximum value returned by the rand function.
This value is library-dependent, but is guaranteed to be at least 32767 on any standard library implementation.
To generate a random number between min and max, and they should be long data type use:
long randamNum = rand()%(max-min + 1) + min;
(Includes max and min)
For more clearity refer Generating random integer from a range