random numbers

Jonas Heyman jonas at lkbpyr.UUCP
Mon Jan 1 03:47:21 AEST 1990


Hello,

I want this program below to generate 10 different randomly numbers,
but it seems to generate the same ten when you execute the c program.

How do I solve this ?

-----------------------------
main()
{
	int number=0;
	int i=0;

	while (i<10) {
	i++;
	number=rnd();
	printf("%d\n",number);
	}
}

rnd()
{
	int i=0;
	int long now;
	
	srand(time(&now)%37);
	return(rand());
}

------------------------------------

Sincerely Jonas

-- 

  jonas at lkbpyr.lkb.se 



More information about the Comp.lang.c mailing list