From 46b6efbd694647ec988f0b76dca9a8a754cf3e79 Mon Sep 17 00:00:00 2001 From: Hofmann Jonas Date: Fri, 31 Oct 2025 01:50:00 +0100 Subject: [PATCH] began developing concept for readWords --- Start_Windows/input.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 64ad407..f887d73 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -2,11 +2,13 @@ #include #include -static char *singleWordBuffer; +static char *buffer; // TODO: // eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. + +/* char *readSingleWord(FILE *file) { if (file == NULL) @@ -18,9 +20,29 @@ char *readSingleWord(FILE *file) fgets(singleWordBuffer, MAX_LINE_LEN, file); } - +*/ + // Read words from file and store in 'words' array +int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) +{ + int i = 0; + int numberOfReadWords = 0; + char currentChar = 0; + + + do + { + fgetc(file + i); + + i++; + } while (currentChar != EOF); + + + + return numberOfReadWords; +} + /*