I learn C++ in school and there we use Turbo C++. However at home I use either Dev C++ or terminal in Ubuntu to compile programs.
The functions randomize() and random() are used regularly and we include stdlib.h to call them. But in Dev and terminal i get an error saying that the function does not exist.
What could be the reason for this and what can I use as a substitute?
2 Answers
These are not standard C or C++ functions. In standard C and C++ there are srand and rand which are part of the <stdlib.h> header.
These functions are probably part of Turbo C++ to improve compatibility with Turbo Pascal, where randomize and random are the default random number generator.
Unfortunately the quality of this generator sucks very very much. Modern C++ has better alternatives, but since both Turbo C++ and Dev++ are pretty old, you won't be able to use them.
1 Comment
The function which you are talking about has been replaced from standards, some compiler however still continue to support them, but you wont find these function in gcc compier (in your case ubuntu terminal) now in standard there are two function in library <cstdlib> (stdlib.h) rand and srand. You should use them to achieve your purpose. for your reference http://www.cplusplus.com/reference/cstdlib/
rand()?