Is there a function to generate a random int number in C? Or will I have to use a third party library?
Well, STL is C++, not C, so I don't know what you want. If you want C, however, there is the rand()
and srand()
functions:
int rand(void);
void srand(unsigned seed);
These are both part of ANSI C. There is also the random()
function:
long random(void);
But as far as I can tell, random()
is not standard ANSI C. A third-party library may not be a bad idea, but it all depends on how random of a number you really need to generate.