From 83b8ac3e87606a9a84dddbf740a996e9b21106b3 Mon Sep 17 00:00:00 2001 From: Ben Skuppin Date: Sun, 2 Nov 2025 15:31:01 +0100 Subject: [PATCH] input in char einlesen und mit sotierung in char words begonnen --- Start_Windows/input.c | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Start_Windows/input.c b/Start_Windows/input.c index 9b802e8..06d0041 100644 --- a/Start_Windows/input.c +++ b/Start_Windows/input.c @@ -8,7 +8,49 @@ // Read words from file and store in 'words' array int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) { - file = fopen("words.txt", "r"); //liest das doc ein + /*file = fopen("words.txt", "r"); //liest das doc ein if (file == NULL) - return -1; + return -1;*/ + FILE *ptr; + char text [2000]; + char line[200]; + char value; + int i = 0; + int start = 0, end= 0; + + ptr = fopen("words.txt", "r"); + if (ptr == NULL) { + printf("Datei konnte nicht geƶffnet werden.\n"); + return 1; + } + + while (fgets(line, sizeof(line), ptr)) { + for (int j = 0; line[j] != '\0'&& i < sizeof(text)-1;j++) { + text[i++] = line[j]; + } + + } + text[i] = '\0'; + + fclose(ptr); + + printf("%s\n", text); + + for (int k = 0 ; k == sizeof(text) || value == '\0' ; k++ ) { + text[k]=value; + if ((value == '\n') || (value ==' ') || ( value == ',')|| ( value == ';')) + { + end = k-1; + + } + } + + + + + + + fclose(ptr); + + } \ No newline at end of file