From 48c0aadace68fcee7e5d2438572347009213b82d Mon Sep 17 00:00:00 2001 From: gloecknerni100842 Date: Mon, 20 Oct 2025 14:55:17 +0200 Subject: [PATCH 1/3] Game Output implementiert --- I2_Wortsalat/Start_Mac/input.c | 25 +++++++++++++++++++++++++ I2_Wortsalat/Start_Windows/game.c | 10 +++++++++- I2_Wortsalat/Start_Windows/input.c | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/I2_Wortsalat/Start_Mac/input.c b/I2_Wortsalat/Start_Mac/input.c index ed77805..9c4ef16 100644 --- a/I2_Wortsalat/Start_Mac/input.c +++ b/I2_Wortsalat/Start_Mac/input.c @@ -8,5 +8,30 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + char lines [1024]; //TODO: Sinnvolle Begrenzung finden + int word_counter = 0; + while (fgets(lines, sizeof(lines) , file) != NULL) + { + for (int i = 0; lines[i] != '\0'; i++) //Entfernen von \n aus dem String + { + if (lines[i] == '\n') + { + lines[i] = '\0'; + break; + } + } + + char *single_word = strtok(lines, " ;,"); + + while (single_word != NULL && word_counter < maxWordCount) + { + strncpy(words[word_counter], single_word, MAX_WORD_LEN - 1); + words [word_counter][MAX_WORD_LEN -1] = '\0'; //Zur Sicherheit, damit \0 auf alle Fälle vorhanden ist + word_counter++; + single_word = strtok(NULL, " ;,"); + } + } + + return word_counter; } \ No newline at end of file diff --git a/I2_Wortsalat/Start_Windows/game.c b/I2_Wortsalat/Start_Windows/game.c index d8cc133..b9d31a9 100644 --- a/I2_Wortsalat/Start_Windows/game.c +++ b/I2_Wortsalat/Start_Windows/game.c @@ -14,10 +14,18 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) { + + } // Prints the word salad to console void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) { - + for( int i = 0; i < searchFieldLen; i++ ) + { + for( int j = 0; j < searchFieldLen; j++ ) + { + printf("%c", salad[i][j]); + } + } } diff --git a/I2_Wortsalat/Start_Windows/input.c b/I2_Wortsalat/Start_Windows/input.c index ed77805..9c4ef16 100644 --- a/I2_Wortsalat/Start_Windows/input.c +++ b/I2_Wortsalat/Start_Windows/input.c @@ -8,5 +8,30 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { + char lines [1024]; //TODO: Sinnvolle Begrenzung finden + int word_counter = 0; + while (fgets(lines, sizeof(lines) , file) != NULL) + { + for (int i = 0; lines[i] != '\0'; i++) //Entfernen von \n aus dem String + { + if (lines[i] == '\n') + { + lines[i] = '\0'; + break; + } + } + + char *single_word = strtok(lines, " ;,"); + + while (single_word != NULL && word_counter < maxWordCount) + { + strncpy(words[word_counter], single_word, MAX_WORD_LEN - 1); + words [word_counter][MAX_WORD_LEN -1] = '\0'; //Zur Sicherheit, damit \0 auf alle Fälle vorhanden ist + word_counter++; + single_word = strtok(NULL, " ;,"); + } + } + + return word_counter; } \ No newline at end of file From 2579dede527d4bc8547b3ee9297785a0dcf61819 Mon Sep 17 00:00:00 2001 From: gloecknerni100842 Date: Mon, 20 Oct 2025 15:29:55 +0200 Subject: [PATCH 2/3] Game Output implementiert --- .idea/editor.xml | 344 ++++++++++++++++++++++++++++ .idea/vcs.xml | 6 + .idea/workspace.xml | 94 ++++++++ I2_Wortsalat/.idea/.gitignore | 8 + I2_Wortsalat/.idea/I2_Wortsalat.iml | 8 + I2_Wortsalat/.idea/editor.xml | 102 +++++++++ I2_Wortsalat/.idea/modules.xml | 8 + I2_Wortsalat/.idea/vcs.xml | 6 + I2_Wortsalat/Start_Windows/main.c | 16 +- 9 files changed, 590 insertions(+), 2 deletions(-) create mode 100644 .idea/editor.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 I2_Wortsalat/.idea/.gitignore create mode 100644 I2_Wortsalat/.idea/I2_Wortsalat.iml create mode 100644 I2_Wortsalat/.idea/editor.xml create mode 100644 I2_Wortsalat/.idea/modules.xml create mode 100644 I2_Wortsalat/.idea/vcs.xml diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..25c6c37 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,344 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..41c7950 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + { + "associatedIndex": 4 +} + + + + { + "keyToString": { + "C/C++ File.main.c.executor": "Run", + "ModuleVcsDetector.initialDetectionPerformed": "true", + "RunOnceActivity.RadMigrateCodeStyle": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.cidr.known.project.marker": "true", + "RunOnceActivity.git.unshallow": "true", + "RunOnceActivity.readMode.enableVisualFormatting": "true", + "cf.first.check.clang-format": "false", + "cidr.known.project.marker": "true", + "git-widget-placeholder": "main", + "ignore.virus.scanning.warn.message": "true", + "last_opened_file_path": "C:/Users/nico/Documents/C-Projekte/I2_Projects", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + 1760360744807 + + + + + + \ No newline at end of file diff --git a/I2_Wortsalat/.idea/.gitignore b/I2_Wortsalat/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/I2_Wortsalat/.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/I2_Wortsalat/.idea/I2_Wortsalat.iml b/I2_Wortsalat/.idea/I2_Wortsalat.iml new file mode 100644 index 0000000..bc2cd87 --- /dev/null +++ b/I2_Wortsalat/.idea/I2_Wortsalat.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/I2_Wortsalat/.idea/editor.xml b/I2_Wortsalat/.idea/editor.xml new file mode 100644 index 0000000..e54e87a --- /dev/null +++ b/I2_Wortsalat/.idea/editor.xml @@ -0,0 +1,102 @@ + + + + + \ No newline at end of file diff --git a/I2_Wortsalat/.idea/modules.xml b/I2_Wortsalat/.idea/modules.xml new file mode 100644 index 0000000..016ae66 --- /dev/null +++ b/I2_Wortsalat/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/I2_Wortsalat/.idea/vcs.xml b/I2_Wortsalat/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/I2_Wortsalat/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/I2_Wortsalat/Start_Windows/main.c b/I2_Wortsalat/Start_Windows/main.c index 03da755..7423b6f 100644 --- a/I2_Wortsalat/Start_Windows/main.c +++ b/I2_Wortsalat/Start_Windows/main.c @@ -38,13 +38,25 @@ int main(int argc, char *argv[]) // TODO: // Check if all words were successfully placed - // Start the game if successful - // error message if some words couldn't be placed + if(placedWords == wordCount) + { + printf("Eingabe war erfolgreich!\nDas Spiel beginnt:"); + void startGame(wordSalad[][], searchFieldSize, words[][], numberOfWords, windowSize) + } + else + { + printf("Fehler! Es konnten nicht alle Woerter hinzugefuegt werden!\n Bitte Spiel neustarten!"); + } + // Start the game if successful + + + // error message if some words couldn't be placed } else { // Print error message if file couldn't be opened + fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]); exitCode = EXIT_FAILURE; } From c745cdd1485fada5f1240113eb1df9471303b219 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 21 Oct 2025 15:00:57 +0200 Subject: [PATCH 3/3] updated files in StartMac --- .gitignore | 7 +++++++ I2_Wortsalat/Start_Mac/.DS_Store | Bin 0 -> 6148 bytes I2_Wortsalat/Start_Mac/game.c | 8 +++++++- I2_Wortsalat/Start_Mac/main.c | 13 ++++++++++--- I2_Wortsalat/Start_Mac/makefile | 24 +++++++++++++----------- I2_Wortsalat/Start_Windows/main.c | 19 +++++++------------ 6 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 .gitignore create mode 100644 I2_Wortsalat/Start_Mac/.DS_Store diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1e82b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +I2_Wortsalat/.DS_Store +I2_Wortsalat/Start_Mac/game.c +I2_Wortsalat/Start_Mac/game.o +I2_Wortsalat/Start_Mac/input.o +I2_Wortsalat/Start_Mac/main.o +I2_Wortsalat/Start_Mac/runTests +I2_Wortsalat/Start_Mac/wordsalad_initial diff --git a/I2_Wortsalat/Start_Mac/.DS_Store b/I2_Wortsalat/Start_Mac/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0