Use standard C function rand

I was trying to compile the example with Visual C++, and it complained about the use of `random()`. I changed it to use the standard C library function `rand()`.