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
|
||||
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);
|
||||
|
||||
while (token != NULL && count < maxWordCount) {
|
||||
// Alles in Großbuchstaben umwandeln
|
||||
for (int i = 0; token[i]; i++) {
|
||||
token[i] = toupper(token[i]);
|
||||
}
|
||||
|
||||
// Wort ins Array kopieren
|
||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||
words[count][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung
|
||||
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||
count++;
|
||||
|
||||
token = strtok(NULL, delimiters);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
return count;
|
||||
|
||||
return count; // Datei nicht schließen – gehört dem Aufrufer
|
||||
}
|
||||
@ -62,7 +62,9 @@ int main(int argc, char *argv[])
|
||||
if(placedWords == wordCount)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
|
||||
@ -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