The rand_s function writes a pseudorandom integer in the range 0 to UINT_MAX to the input pointer. The rand_s function uses the operating system to generate cryptographically secure random numbers. It does not use the seed generated by the srand function, nor does it affect the random number sequence used by rand.
The rand_s function requires that constant _CRT_RAND_S be defined prior to the inclusion statement for the function to be declared, as in the following example:
#define _CRT_RAND_S
#include <stdlib.h>
rand_s depends on the RtlGenRandom API, which is only available in Windows XP and later.