Makefile überarbeitet; readWords() implementiert; createWordSalad implementiert; main.c fertiggestellt und unsere Namen zu words.txt hinzugefügt

This commit is contained in:
schuhmannlo105927 committed 2026-11-03 10:38:52 +01:00
1 parent f2e54529a4
commit fb760d76fe
5 files changed
+111 -9

No files matched your search

+23
View File
@@ -8,5 +8,28 @@
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
const char *delim = ", ; \n\t";
char buffer[MAX_WORD_LEN * MAX_WORD_LEN];
int i = 0; // Wort-Zähler
// Prüfen, ob das Lesen erfolgreich war (EOF oder Fehler abfangen)
while (fgets(buffer, sizeof(buffer), file) != NULL && i<maxWordCount) {
char *wordbuffer = strtok(buffer, delim);
while (wordbuffer != NULL && i<maxWordCount) {
// snprintf ist quasi strncpy nur mit \0 und sicher
snprintf(words[i], MAX_WORD_LEN, "%s", wordbuffer);
for (int j=0; words[i][j] != '\0'; j++) {
words[i][j] = toupper((unsigned char)words[i][j]);
}
wordbuffer = strtok(NULL, delim);
i++;
}
}
return i;
}