If I replace srand()/rand() with srandom()/random(), is RAND_MAX is still there?

or I need to change to use something like RANDOM_MAX?

which version of generating the random number is more portable? Cause I encountered using srand()/rand() in my program. And this program works in my i7 computer, but not working in AMD clusters. Strange, please help out. Thanks.
Last edited on
rand() is a standard C function http://en.cppreference.com/w/c/numeric/random/rand and is the most portable option.

rand() is also available in C++ http://en.cppreference.com/w/cpp/numeric/random/rand , although C++ has far better random number generation facilities in the header <random> http://en.cppreference.com/w/cpp/numeric/random

random() a POSIX function: http://pubs.opengroup.org/onlinepubs/9699919799/functions/random.html - it is less portable than any function from C or C++

Topic archived. No new replies allowed.