Compare commits
4 Commits
main
...
Version_1.
| Author | SHA1 | Date | |
|---|---|---|---|
| 099ea7285d | |||
| 70236c1e01 | |||
| b7e729182c | |||
| e4b502149d |
@ -1,7 +1,7 @@
|
||||
#include "game.h" // Einbindung der Header-Datei mit Funktionsdeklarationen und Konstanten
|
||||
#include <time.h> // Für die Initialisierung des Zufallszahlengenerators
|
||||
#include <stdlib.h> // Für rand(), srand() und Speicherfunktionen
|
||||
#include <string.h> // Für strlen() zur Ermittlung der Wortlänge
|
||||
#include <string.h> // Für strlen() zur Ermittlung der Wortlänge
|
||||
#include <stdio.h> // Für printf() in showWordSalad
|
||||
|
||||
#define MAX_RAND_TRIES_PER_WORD 10 // Maximale Versuche, ein Wort zufällig zu platzieren
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -4,6 +4,10 @@
|
||||
#include "game.h"
|
||||
#include "graphicalGame.h"
|
||||
|
||||
|
||||
//test änderung john.n
|
||||
|
||||
|
||||
#define MAX_NUMBER_OF_WORDS 100
|
||||
#define SALAD_SIZE 20
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user