I have to write a program that will run a random guessing game. The game is to be numbers from 1-100, the guesser gets 20 tries and at the end is supposed to be asked if they wo
May I suggest using the gettimeofday function, as a way to provide a seed to your random function?
#include
#include
#include
//clock_t times(struct tms *buffer);
int
main(int argc, char **argv)
{
int a;
struct timeval _wall;
gettimeofday( &_wall, NULL ); //(_wall.tv_sec,_wall.tv_usec);
srand(_wall.tv_usec);
a = rand() % 100 + 1;
printf("%d\n",a);
return 0;
}