C
C
Generating Random Integer in Range
See more PRNG Examples
Demonstrates how to generate random integers in a specified range.Chilkat C Downloads
#include <C_CkPrng.h>
void ChilkatSample(void)
{
BOOL success;
HCkPrng fortuna;
int i;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
success = FALSE;
fortuna = CkPrng_Create();
// Generate random integers between 12 and 24 inclusive
for (i = 0; i <= 100; i++) {
printf("%d\n",CkPrng_RandomInt(fortuna,12,24));
}
CkPrng_Dispose(fortuna);
}