Mail Archives: djgpp/1998/01/28/20:18:00
I have tried to do random numbers before without success. Now I think I know
why. In the info documentation's alphabetical list, there is no mention of
srand(). And there's no cross reference to srand() from rand().
I was able to glean from this thread that you're supposed to do something like
this:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <bios.h>
int main(void)
{
char c;
while((c=bioskey(0))!='x'){
printf("%-10c", c);
srand(time(0));
printf("And the random number is... %d\n", rand());
}
return 0;
}
But if this is right, how would a beginner find it out? (Besides, of course,
reading about it from an outside source.)
--Ed (Myknees)
- Raw text -