<cstdlib>provides int rand (). You might want to check the man page. If your system is longer than int, you can call rand () twice and put the first value in the upper word.
#include <cstdlib>
long lrand()
{
if (sizeof(int) < sizeof(long))
return (static_cast<long>(rand()) << (sizeof(int) * 8)) |
rand();
return rand();
}
(it is very unlikely that long is neither the same nor the double size of int, so this is practical, if not theoretically perfect)
rand(). , . srand() . , Windows sizeof (int), .