31 lines
675 B
C

#include <stdio.h>
#include <string.h>
#define MAX_WORDS 100
#define MAX_WORD_LEN 50
int main() {
const char *filename = "words.txt"; // Datei mit Wörtern
char words[MAX_WORDS][MAX_WORD_LEN];
int count = 0;
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]);
}
return 0;
}