summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorrafa_99 <rafa99@protonmail.com>2020-12-04 03:31:45 +0000
committerrafa_99 <rafa99@protonmail.com>2020-12-04 03:31:45 +0000
commit7be4deeee60d11e3ae09ddef1147b2a93b183d88 (patch)
treeb566529d788449442b95fe6a2f0ec41e657a7c45 /utils.c
parent650fb220913f79b5016dcfe1e497493619bf6fa2 (diff)
Pushed Working Board
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/utils.c b/utils.c
index 49a6069..e349368 100644
--- a/utils.c
+++ b/utils.c
@@ -1,7 +1,8 @@
#include <stdio.h>
-#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
+#include <unistd.h>
#include <sys/time.h>
#include "utils.h"
@@ -10,6 +11,16 @@ int checkIfFileExists(char *path)
return access(path, F_OK);
}
+int numerize(char *string)
+{
+ int val = 0;
+ for( int i = 0; i < strlen(string); i++ )
+ {
+ val += string[i];
+ }
+ return val;
+}
+
int lineCounter(FILE *dictionary)
{
int words = 0;
@@ -41,12 +52,12 @@ char* getLine(FILE *dictionary, int lineNumber)
return line;
}
-int getRandomNumber(int min, int max)
+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)) + (randtime.tv_usec / 100 - time(NULL)));
+ srand(((randtime.tv_sec * 100) + time(NULL) * numerize(question)) + ((randtime.tv_usec / 100) - time(NULL) * numerize(question)));
return ((rand() % (max - min + 1)) + 1);
}