Sunday, 27 January 2013

rand_s

As we know the rand function in C++ generates a pseudo random number. The rand_s function is a version
of the rand function with security enhancements.

If you ever have wanted to use the security enhanced version ,rand_s,  and after including the
necessary reference to the stdlib library  , #include ,  you still get a compile error error C3861:

error C3861: 'rand_s': identifier not found

You will need to include a macro on your code. My personal choice, which  I found more convenient,
is to add the macro _CRT_RAND_S in the "C++\Preprocessor  property page






You can find more information on rand_s on this following MDSN page

2 comments: