The random() function from stdlib.h is actually a POSIX function, not a C one. So it is only guaranteed to be available in POSIX systems, such as Linux.
If you want to be portable to other C environments, use rand().
Or if you use C++, as your tag suggest, and a not too old compiler, you can use the functions from <random>.
solved Why does random() not work in windows? [closed]