diff --git a/Start_Windows/input.c b/Start_Windows/input.c index ed77805..6c1556b 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -1,12 +1,25 @@ +#include #include "input.h" -#include -#include -// TODO: -// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt. +#define MAX_WORDS 100 +#define MAX_WORD_LEN 20 -// Read words from file and store in 'words' array -int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) -{ +int main() { + FILE *file = fopen("words.txt", "r"); + if (!file) { + perror("Datei konnte nicht geöffnet werden"); + return 1; + } + char words[MAX_WORDS][MAX_WORD_LEN]; + int wordCount = readWords(file, words, MAX_WORDS); + + fclose(file); + + printf("Es wurden %d Wörter eingelesen:\n", wordCount); + for (int i = 0; i < wordCount; i++) { + printf("%s\n", words[i]); + } + + return 0; } \ No newline at end of file