summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
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);
}