input und anzeige überarbeitet
This commit is contained in:
parent
817ddc0e35
commit
9d8a760f08
@ -14,23 +14,25 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
// Alle gewünschten Trennzeichen
|
// Alle gewünschten Trennzeichen
|
||||||
const char *delimiters = " \t\n,.;:!?\"'()[]{}";
|
const char *delimiters = " \t\n,.;:!?\"'()[]{}";
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), file) && count < maxWordCount) {
|
// Zeile für Zeile lesen
|
||||||
|
while (fgets(line, sizeof(line), file) != NULL && count < maxWordCount) {
|
||||||
|
// Tokenize Zeile nach Trennzeichen
|
||||||
char *token = strtok(line, delimiters);
|
char *token = strtok(line, delimiters);
|
||||||
|
|
||||||
while (token != NULL && count < maxWordCount) {
|
while (token != NULL && count < maxWordCount) {
|
||||||
// Alles in Großbuchstaben umwandeln
|
// Alles in Großbuchstaben umwandeln
|
||||||
for (int i = 0; token[i]; i++) {
|
for (int i = 0; token[i]; i++) {
|
||||||
token[i] = toupper(token[i]);
|
token[i] = toupper(token[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wort ins Array kopieren
|
||||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||||
words[count][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung
|
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
token = strtok(NULL, delimiters);
|
token = strtok(NULL, delimiters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
return count; // Datei nicht schließen – gehört dem Aufrufer
|
||||||
return count;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -62,7 +62,9 @@ int main(int argc, char *argv[])
|
|||||||
if(placedWords == wordCount)
|
if(placedWords == wordCount)
|
||||||
{
|
{
|
||||||
// Start the game with the created word salad
|
// Start the game with the created word salad
|
||||||
startGame(wordSalad, SALAD_SIZE, words, wordCount, placedWords);
|
printf("Squares: %u, Words: %u\n", SALAD_SIZE, placedWords);
|
||||||
|
unsigned int windowWidth = 800;
|
||||||
|
startGame(wordSalad, SALAD_SIZE, words, wordCount, windowWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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