rand() is generally considered as a poor random number generator.
You can use this instead, and it generates a 32 bit result instead of 16 bit
Code:
unsigned long idnum;
unsigned long lrand( )
{
idnum = 1664525L * idnum + 1013904223L;
return idnum;
}