Compare commits

...

4 Commits

3 changed files with 29 additions and 8 deletions

View File

@ -27,7 +27,11 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
for (int tries = 0; tries < MAX_RAND_TRIES_PER_WORD && !placed; tries++) {
int dir = rand() % 2; // Zufällige Richtung: 0 = horizontal, 1 = vertikal
int row = rand() % searchFieldLen; // Zufällige Zeile
} // Ende innere Schleife
} // Ende äußere Schleife
return 0; // Rückgabewert
} // Ende der Funktion
// Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)

View File

@ -1,12 +1,25 @@
#include <stdio.h>
#include "input.h"
#include <string.h>
#include <ctype.h>
// TODO:
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
#define MAX_WORDS 100
#define MAX_WORD_LEN 20
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
int main() {
FILE *file = fopen("words.txt", "r");
if (!file) {
perror("Datei konnte nicht geöffnet werden");
return 1;
}
char words[MAX_WORDS][MAX_WORD_LEN];
int wordCount = readWords(file, words, MAX_WORDS);
fclose(file);
printf("Es wurden %d Wörter eingelesen:\n", wordCount);
for (int i = 0; i < wordCount; i++) {
printf("%s\n", words[i]);
}
return 0;
}

View File

@ -4,6 +4,10 @@
#include "game.h"
#include "graphicalGame.h"
//test änderung john.n
#define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20