diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 9caad62..3917fe2 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -8,21 +8,29 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { - if (file == NULL) { - printf("Datei konnte nicht geoffnet werden"); - return 0; - } - // 2D char Array um wörter zu speichern - char word[MAX_WORD_LEN]; + char line[1024]; // Puffer für eine Zeile unsigned int count = 0; - while (fscanf(file, "%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++; + + // Alle gewünschten Trennzeichen + const char *delimiters = " \t\n,.;:!?\"'()[]{}"; + + while (fgets(line, sizeof(line), file) && count < maxWordCount) { + char *token = strtok(line, delimiters); + while (token != NULL && count < maxWordCount) { + // Alles in Großbuchstaben umwandeln + for (int i = 0; token[i]; i++) { + token[i] = toupper(token[i]); + } + + strncpy(words[count], token, MAX_WORD_LEN - 1); + words[count][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung + count++; + + token = strtok(NULL, delimiters); + } } + fclose(file); return count; - } \ No newline at end of file diff --git a/Start_Windows/main.c b/Start_Windows/main.c index a2aac71..ba3341e 100644 --- a/Start_Windows/main.c +++ b/Start_Windows/main.c @@ -5,7 +5,7 @@ #include "graphicalGame.h" #define MAX_NUMBER_OF_WORDS 100 -#define SALAD_SIZE 30 +#define SALAD_SIZE 20 int main(int argc, char *argv[]) { diff --git a/Start_Windows/words.txt b/Start_Windows/words.txt index 31ee099..30d74d2 100644 --- a/Start_Windows/words.txt +++ b/Start_Windows/words.txt @@ -1,5 +1 @@ -Yeti,Nessie Werwolf; Vampir -Monster -Hydra;Frankenstein -Dracula;KingKong;Gremlin;Kobold,Hexe;Poltergeist -Gespenst, Oger \ No newline at end of file +test \ No newline at end of file