diff --git a/Startcode/input.c b/Startcode/input.c index ed77805..fbe94a6 100644 --- a/Startcode/input.c +++ b/Startcode/input.c @@ -8,5 +8,25 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + char line[1024]; + unsigned int count = 0; + if (file == NULL) + return 0; + + while (count < maxWordCount && fgets(line, sizeof(line), file) != NULL) + { + char *word = strtok(line, ",; \t\r\n"); + + while (word != NULL && count < maxWordCount) + { + strncpy(words[count], word, MAX_WORD_LEN - 1); + words[count][MAX_WORD_LEN - 1] = '\0'; + + count++; + word = strtok(NULL, ",; \t\r\n"); + } + } + + return count; } \ No newline at end of file diff --git a/Startcode/runTests b/Startcode/runTests new file mode 100755 index 0000000..d7706c1 Binary files /dev/null and b/Startcode/runTests differ