You should call srand(time(0)) at the beginning of your program to set the random seed (only once)
Then, any time you want a random number call rand() which returns a number from 0 to RAND_MAX.
If you want a range from 0 to n-1, use rand()%n
Most would recommend random() and srandom(seed) over rand and srand. It works exactly the same way. Just include stdlib.h and seed with srandom(time(0)).
If you are on a windows platform, the best way (without downloading additional libraries) is to use rand_s(). The differences between the different functions listed her would be negligible in most cases though, I'm sure any of these will be fine for your needs.