+ 1

why don't random and randomize() work in Solo learn C ++?

Pls help!

17th Feb 2018, 5:08 PM
Atharv Singh Patlan
Atharv Singh Patlan - avatar
4 Réponses
+ 5
Because they were created by Borland and were never supported by other compilers. You could make your own support, if you really want them.
17th Feb 2018, 5:27 PM
John Wells
John Wells - avatar
+ 2
You should be using neither of those functions. Do this instead: include ctime and cstdlib ... main () { srand (time (nullptr)); cout << rand () % 10 << endl; return 0; } This will output a random number from 0 to 10 each time you run it.
17th Feb 2018, 5:29 PM
Zeke Williams
Zeke Williams - avatar
+ 2
If its a must to use these functions, Why not define them like this? : #define randomize() srand(time(0LL)) #define random(x) (rand()%(x))
18th Feb 2018, 4:56 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 1
I didn't know that's it not supported in other compilers. Just started with c++ on turbo, so didn't know for others. I found s rand somewhat pointless as randomize() was present. Thanks for removing this misconception. And how to comment in solo learn forums?
18th Feb 2018, 1:24 PM
Atharv Singh Patlan
Atharv Singh Patlan - avatar