From 6f92d66b106f3a168608fb62aa0f4f4fc57b1209 Mon Sep 17 00:00:00 2001 From: Simon Schuerer Date: Mon, 3 Nov 2025 13:49:12 +0000 Subject: [PATCH] Start_Windows/game.c aktualisiert --- Start_Windows/game.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/Start_Windows/game.c b/Start_Windows/game.c index fadecf0..ae1a794 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -1,31 +1,29 @@ #include -#include +#include +#include -#define MAX_WORDS 100 -#define MAX_WORD_LEN 50 +#define SIZE 10 // Anzahl der Zeilen in der Spalte + +// Erzeugt eine Spalte mit zufälligen Buchstaben +void createColumn(char column[SIZE]) { + for (int i = 0; i < SIZE; i++) { + column[i] = 'A' + rand() % 26; // Zufälliger Buchstabe A-Z + } +} + +// Gibt die Spalte aus +void showColumn(char column[SIZE]) { + for (int i = 0; i < SIZE; i++) { + printf("%c\n", column[i]); + } +} int main() { - const char *filename = "words.txt"; // Datei mit Wörtern - char words[MAX_WORDS][MAX_WORD_LEN]; - int count = 0; + srand(time(NULL)); // Zufallszahlengenerator initialisieren - FILE *file = fopen(filename, "r"); - if (!file) { - printf("Fehler: Datei %s nicht gefunden!\n", filename); - return 1; - } - - // Wörter aus Datei einlesen - while (fscanf(file, "%49s", words[count]) == 1 && count < MAX_WORDS) { - count++; - } - fclose(file); - - // Wörter ausgeben - printf("Eingelesene Wörter:\n"); - for (int i = 0; i < count; i++) { - printf("%s\n", words[i]); - } + char column[SIZE]; + createColumn(column); + showColumn(column); return 0; } \ No newline at end of file