The input function is done

This commit is contained in:
Widerstand 2025-11-01 20:23:13 +01:00
parent 1273238eb8
commit cc5ca1144a

View File

@ -8,5 +8,21 @@
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
int counter = 0; //word's numbers
char line[MAX_WORD_LEN];
char *word;
}
while (fgets(line, MAX_LINE_LEN, file) != NULL && counter < maxWordCount) {
//printf("%s", line);
word = strtok(line, " ,;");
while (word != NULL && counter < maxWordCount)
{
strcpy(words[counter++], word);
//printf ("%s\n",word);
word = strtok (NULL, " ,;");
}
}
//printf("\n %d", counter);
return counter;
}