input.c fertig 1

This commit is contained in:
Ben Skuppin 2025-11-04 10:10:08 +01:00
parent 8800ac8b5c
commit e7d3cc9023

View File

@ -8,21 +8,11 @@
// 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
if (file == NULL)
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++) {
@ -32,9 +22,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
}
text[i] = '\0';
fclose(ptr);
printf("%s\n", text);
//sortierung der wörter in words(unterhalb)
@ -52,9 +40,10 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
zaehler++;
}
maxWordCount=zaehler;
//alle buchstaben in großbuchstaben ändern
//alle Buchstaben in Großbuchstaben ändern