Fixed random function, add words to UI

This commit is contained in:
Aidan Haas
2022-11-09 18:23:54 -05:00
committed by GitHub
parent a724c75e80
commit 7c11e14c94
4 changed files with 62 additions and 25 deletions
+14 -3
View File
@@ -1,9 +1,20 @@
#include "utilities.h"
#include <time.h>
#include <sys/time.h>
/* Clears word array given in parameters */
void clear_word_array(Word_array *array) {
int i;
for (i = 0; i < array->number_of_words; i++) {
free(array->words[i].text);
}
array->number_of_words = 0;
}
int generate_random(int lower, int upper, int c) {
time_t x;
srand(x);
struct timeval te;
gettimeofday(&te, NULL);
long long milliseconds = te.tv_sec * 1000LL + te.tv_usec / 1000;
srand(milliseconds + c);
return (rand() % (upper - lower + 1)) + lower;
}