Compare commits
4 Commits
main
...
Version_1.
| Author | SHA1 | Date | |
|---|---|---|---|
| 099ea7285d | |||
| 70236c1e01 | |||
| b7e729182c | |||
| e4b502149d |
@ -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++) {
|
for (int tries = 0; tries < MAX_RAND_TRIES_PER_WORD && !placed; tries++) {
|
||||||
int dir = rand() % 2; // Zufällige Richtung: 0 = horizontal, 1 = vertikal
|
int dir = rand() % 2; // Zufällige Richtung: 0 = horizontal, 1 = vertikal
|
||||||
int row = rand() % searchFieldLen; // Zufällige Zeile
|
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
|
// Prints the word salad to console
|
||||||
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
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 "input.h"
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
// TODO:
|
#define MAX_WORDS 100
|
||||||
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
#define MAX_WORD_LEN 20
|
||||||
|
|
||||||
// Read words from file and store in 'words' array
|
int main() {
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
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 "game.h"
|
||||||
#include "graphicalGame.h"
|
#include "graphicalGame.h"
|
||||||
|
|
||||||
|
|
||||||
|
//test änderung john.n
|
||||||
|
|
||||||
|
|
||||||
#define MAX_NUMBER_OF_WORDS 100
|
#define MAX_NUMBER_OF_WORDS 100
|
||||||
#define SALAD_SIZE 20
|
#define SALAD_SIZE 20
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user