diff --git a/Start_Windows/game.o b/Start_Windows/game.o deleted file mode 100644 index f9be5ef..0000000 Binary files a/Start_Windows/game.o and /dev/null differ diff --git a/Start_Windows/graphicalGame.o b/Start_Windows/graphicalGame.o deleted file mode 100644 index b70ae22..0000000 Binary files a/Start_Windows/graphicalGame.o and /dev/null differ diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 025ba18..fdd7ade 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -1,38 +1,38 @@ #include "input.h" #include #include -#include // TODO: // eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. // Read words from file and store in 'words' array -int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { - char zeile[MAX_LINE_LEN]; - char* teiler = ".;, "; //Trennung zwischen den Wörtern einer Zeile - int wordCount = 0; - char* token; // Einzelwort aus Zeile - while(fgets(zeile, MAX_LINE_LEN, file)!=NULL) //Zeilenweises einlesen +int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) +{ + + char puffer[MAX_LINE_LEN]; //Array für eingelesene Zeile + int counter = 0; //Zähler für Anzahl eingelesener Wörter + int i; + + while(fgets(puffer, MAX_LINE_LEN-1, file) != NULL && counter < maxWordCount) { - for (int i = 0; i < MAX_LINE_LEN; i++) + char *word_parts = strtok(puffer, ",;\n\t/. "); //Wörter aufteilen + printf("..."); + while(word_parts != NULL && counter < maxWordCount) { - if (zeile[i] >= 'a'&&zeile[i] <= 'z') //Ersetzen aller Kleinbuchstaben in Großbuchstaben - { - zeile[i]=zeile[i]-32; //ASCII-Code -32 entspricht dem jeweiligen Großbuchstaben - } - if (zeile[i] == '\n') - { - zeile[i] = '\0'; //Ende der Zeile = String Ende - break; - } - } - token = strtok(zeile,teiler); - while(token != NULL && wordCount < maxWordCount) - { - strcpy(words[wordCount],token);//Trennen der Wörter in einer Zeile und kopieren in 2D Array "untereinander" - token = strtok(NULL,teiler); - wordCount++; + printf("!!!!"); + for(i = 0; i < MAX_WORD_LEN -1 && word_parts[i] != '\0'; i++) + { + printf("????"); + + words[counter][i] = toupper(word_parts[i]); //Großbuchstaben erzeugen + } + words[counter][i] = '\0'; //Stringdefinition vervollständigen + + counter++; // Wort eingelesen, Wortzähler erhöhen + word_parts = strtok(NULL, ",;\n\t/. "); //NULL für Zeiger angeben + } + } - return wordCount; + return counter; } \ No newline at end of file diff --git a/Start_Windows/input.o b/Start_Windows/input.o deleted file mode 100644 index 5acb56c..0000000 Binary files a/Start_Windows/input.o and /dev/null differ diff --git a/Start_Windows/main.o b/Start_Windows/main.o deleted file mode 100644 index 5d2f7f6..0000000 Binary files a/Start_Windows/main.o and /dev/null differ diff --git a/Start_Windows/wordsalad.exe b/Start_Windows/wordsalad.exe deleted file mode 100644 index 4afc154..0000000 Binary files a/Start_Windows/wordsalad.exe and /dev/null differ