#include #include #include "../rand.h" #define TEST_SEED 0x19610910 #define TIMES 3 int main(void) { int i; unsigned myseed; printf("seeding bsdrand with 0x%x: \n", TEST_SEED); bsdsrand(TEST_SEED); printf("generating three pseudo-random numbers:\n"); for (i = 0; i < TIMES; i++) { printf("next random number = %d\n", bsdrand()); } printf("generating the same sequence with rand_r:\n"); myseed = TEST_SEED; for (i = 0; i < TIMES; i++) { printf("next random number = %d\n", rand_r(&myseed)); } return 0; }