diff --git a/Start_Windows/game.o b/Start_Windows/game.o deleted file mode 100644 index 884781f..0000000 Binary files a/Start_Windows/game.o and /dev/null differ diff --git a/Start_Windows/input.c b/Start_Windows/input.c index fdd7ade..025ba18 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 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) +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 { - char *word_parts = strtok(puffer, ",;\n\t/. "); //Wörter aufteilen - printf("..."); - while(word_parts != NULL && counter < maxWordCount) + for (int i = 0; i < MAX_LINE_LEN; i++) { - 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 - + 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++; } - } - return counter; + return wordCount; } \ No newline at end of file diff --git a/Start_Windows/input.o b/Start_Windows/input.o deleted file mode 100644 index 806ff55..0000000 Binary files a/Start_Windows/input.o and /dev/null differ diff --git a/Start_Windows/runTests2.exe b/Start_Windows/runTests2.exe deleted file mode 100644 index c5d6ed0..0000000 Binary files a/Start_Windows/runTests2.exe and /dev/null differ