#include
#include
#include
#include
int main() {
int i =10;
/* initialize random seed: */
This solve the problem:
srand48((long int)time(NULL));
i= (lrand48()/rand()+1) % 123
I havent tested with fork, but inside a for calling 100 times it works.
seed with the pid number. It's a little but difficult to solve problem.
This was in some page: "this worked srand(time(0)+getpid()); but I had to call this within the case 0 i.e child process".