Is there a function to generate a random int number in C? Or will I have to use a third party library?
Try this, I put it together from some of the concepts already referenced above:
/*
Uses the srand() function to seed the random number generator based on time value,
then returns an integer in the range 1 to max. Call this with random(n) where n is an integer, and you get an integer as a return value.
*/
int random(int max) {
srand((unsigned) time(NULL));
return (rand() % max) + 1;
}