I'm looking to implement something similar to python's random.randint in C.
I would do something like:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
srand(time(NULL));
int randInt(int lBound, int uBound){
return (rand()%(uBound-lBound+1))+lbound;
}
but if RAND_MAX is not a multiple of uBound, then distribution will be slight skewed.
Is there a quick and dirty way that's better?