ToDo 2D char Array
This commit is contained in:
parent
02b4cb3b9b
commit
eb15c18771
@ -13,6 +13,17 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
printf("words,txt konnte nicht geoffnet werden");
|
printf("words,txt konnte nicht geoffnet werden");
|
||||||
}
|
}
|
||||||
// ToDo 2D char Array um wörter zu speichern kommt hier hin
|
// ToDo 2D char Array um wörter zu speichern kommt hier rein
|
||||||
|
char word[MAX_WORD_LEN];
|
||||||
|
unsigned int count = 0;
|
||||||
|
while (fscanf(textdokument, "%s", word) != EOF && count < maxWordCount) {
|
||||||
|
// Kopiere das gelesene Wort in das 2D-Array
|
||||||
|
strncpy(words[count], word, MAX_WORD_LEN - 1);
|
||||||
|
words[count][MAX_WORD_LEN - 1] = '\0'; // Sicherstellen, dass der String nullterminiert ist
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
fclose(textdokument);
|
||||||
|
return count;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user