The input function is done
This commit is contained in:
parent
1273238eb8
commit
cc5ca1144a
@ -8,5 +8,21 @@
|
|||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' array
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
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;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user