+ 1
why don't random and randomize() work in Solo learn C ++?
Pls help!
4 Antworten
+ 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.
+ 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.
+ 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))
+ 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?