@Antique
Like with any other pseudo random number generator before using rand() you need to seed it using the srand() function.
A common, portable way to seed it is to use the output of time(NULL):
srand(time(NULL));
If you seed it using the same value you will get the same sequence of numbers from it (this can have it's uses).
If you want really random numbers at cost of portability you can also use the RANDOM: device of AmigaOS (just open it as a file and read from it) or alternately you can use the entropy unit of timer.device directly as I do in my
mkpasswd program (source code included).