input bearbeitet

This commit is contained in:
Alexei Keller 2025-11-06 11:47:49 +01:00
parent 1db2042e38
commit 1fb5db8a4f

View File

@ -8,5 +8,22 @@
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
char trennzeichen = " ,;";
char zeile [MAX_LINE_LEN]; //1024
int anzahlWörter;
while (fgets(zeile, MAX_WORD_LEN - 1, file) != 0){
char *token = strtok(zeile, trennzeichen);
while (token != NULL)
{
// Wort ins Array kopieren, Länge begrenzen
strncpy(words[anzahlWörter], token, MAX_WORD_LEN - 1);
words[anzahlWörter][MAX_WORD_LEN - 1] = '\0';
anzahlWörter++;
if (anzahlWörter >= maxWordCount) break;
*token = strtok(NULL, trennzeichen);
}
}
}