summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorrafa_99 <rafa99@protonmail.com>2020-12-15 23:05:17 +0000
committerrafa_99 <rafa99@protonmail.com>2020-12-15 23:05:17 +0000
commit5eba64da58978824f99259ea221a13b21f335a21 (patch)
tree17fdcf319acbbdbaf4c86df60ac1719ecbba9caf /utils.c
parent88d777a152d74a49c04d06b780758cd14a33dc8f (diff)
Added Documentation and Updated Fast Seeded Number Generator
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/utils.c b/utils.c
index e349368..83bfdd2 100644
--- a/utils.c
+++ b/utils.c
@@ -54,10 +54,9 @@ char* getLine(FILE *dictionary, int lineNumber)
int getRandomNumber(int min, int max, char *question)
{
- // Adding Randomize Time Values for Less Chances of Running into Seed Collisions
- struct timeval randtime;
- gettimeofday(&randtime,NULL);
- srand(((randtime.tv_sec * 100) + time(NULL) * numerize(question)) + ((randtime.tv_usec / 100) - time(NULL) * numerize(question)));
+ struct timespec s;
+ clock_gettime(CLOCK_REALTIME, &s);
+ srand(s.tv_nsec * numerize(question));
- return ((rand() % (max - min + 1)) + 1);
+ return ((rand() % (max - min + 1)) + min);
}