diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..1f0ef49 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,580 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 949ef93..4922fd9 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -4,8 +4,27 @@ // 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 buffer[101]; // prepares a large enough buffer to read one line from the .txt-file + char *wordseperator = " ,;"; // sets up checks for seperated words + char *token; + int readwords = 0; + + while (readwords < maxWordCount) { + + do { + token = strtok(buffer, wordseperator); + } while (*token == ' ' || *token == ',' || *token == ';'); + if (strlen(token) <= MAX_WORD_LEN) { + for (int i = 0; i < strlen(token); i++) { + words[readwords][i] = token[i]; + } + readwords++; + } + token = strtok(NULL, wordseperator); + } + + return 0; }