Compare commits
No commits in common. "0c086b96072334f87756142d99752dff150dfafa" and "5162e9890d76a5713b7af03a8b0b4b761c3e9f15" have entirely different histories.
0c086b9607
...
5162e9890d
Binary file not shown.
@ -8,29 +8,21 @@
|
|||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' array
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||||
{
|
{
|
||||||
char line[1024]; // Puffer für eine Zeile
|
if (file == NULL) {
|
||||||
unsigned int count = 0;
|
printf("Datei konnte nicht geoffnet werden");
|
||||||
|
return 0;
|
||||||
// Alle gewünschten Trennzeichen
|
}
|
||||||
const char *delimiters = " \t\n,.;:!?\"'()[]{}";
|
// 2D char Array um wörter zu speichern
|
||||||
|
char word[MAX_WORD_LEN];
|
||||||
while (fgets(line, sizeof(line), file) && count < maxWordCount) {
|
unsigned int count = 0;
|
||||||
char *token = strtok(line, delimiters);
|
while (fscanf(file, "%s", word) != EOF && count < maxWordCount) {
|
||||||
while (token != NULL && count < maxWordCount) {
|
// Kopiere das gelesene Wort in das 2D-Array
|
||||||
// Alles in Großbuchstaben umwandeln
|
strncpy(words[count], word, MAX_WORD_LEN - 1);
|
||||||
for (int i = 0; token[i]; i++) {
|
words[count][MAX_WORD_LEN - 1] = '\0'; // Sicherstellen, dass der String nullterminiert ist
|
||||||
token[i] = toupper(token[i]);
|
count++;
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
|
||||||
words[count][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung
|
|
||||||
count++;
|
|
||||||
|
|
||||||
token = strtok(NULL, delimiters);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1 +1,5 @@
|
|||||||
test
|
Yeti,Nessie Werwolf; Vampir
|
||||||
|
Monster
|
||||||
|
Hydra;Frankenstein
|
||||||
|
Dracula;KingKong;Gremlin;Kobold,Hexe;Poltergeist
|
||||||
|
Gespenst, Oger
|
||||||
Loading…
x
Reference in New Issue
Block a user