Compare commits

...
6 Commits
Author SHA1 Message Date
zirnsackja100494 673b381e04 merge upstream 2025-10-24 12:09:35 +00:00
Giorgi Kesidis 2d66437324 input funktion stand 24.10 2025-10-24 13:59:35 +02:00
Giorgi Kesidis 1c919cb6e3 22.10 2025-10-22 00:22:37 +02:00
Giorgi Kesidis 6f3446fa8d 21.10 2025-10-22 00:21:17 +02:00
Giorgi Kesidis db1e31f237 21.10 2025-10-21 15:29:47 +02:00
Giorgi Kesidis a9d6d69bc1 hallo 2025-10-14 15:09:42 +02:00
6 changed files with 38 additions and 6 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
// Creates the word salad by placing words randomly and filling empty spaces // Creates the word salad by placing words randomly and filling empty spaces
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
{ {
Printf("Hello World+1");
} }
// Prints the word salad to console // Prints the word salad to console
+26 -1
View File
@@ -8,5 +8,30 @@
// Read words from file and store in 'words' array // Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{ {
//kein fopen und close nötig, weil dies schon in der main passiert und mit *file übergeben wird//
} if (!file)
{
perror("Error invalid pointer to file");
return -1;
}
char line[1024];
unsigned int count = 0;
while (fgets(line, sizeof(line), file) && count < maxWordCount)
{
line[strcspn(line, "\n")] = '\0';
char *token = strtok(line, " ;,");
while (token && count < maxWordCount)
{
strcpy(words[count], token);
count++;
token = strtok(NULL, " ;,");
}
}
return count;
}
Binary file not shown.
+10 -3
View File
@@ -12,7 +12,7 @@ int main(int argc, char *argv[])
int exitCode = EXIT_SUCCESS; int exitCode = EXIT_SUCCESS;
// Check if the correct number of arguments is provided // Check if the correct number of arguments is provided
if(argc != 2) if (argc != 2)
{ {
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]); fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
exitCode = EXIT_FAILURE; exitCode = EXIT_FAILURE;
@@ -24,7 +24,7 @@ int main(int argc, char *argv[])
FILE *file = fopen(argv[1], "r"); FILE *file = fopen(argv[1], "r");
if(file != NULL) if (file != NULL)
{ {
unsigned int placedWords = 0; unsigned int placedWords = 0;
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
@@ -40,7 +40,14 @@ int main(int argc, char *argv[])
// Check if all words were successfully placed // Check if all words were successfully placed
// Start the game if successful // Start the game if successful
// error message if some words couldn't be placed // error message if some words couldn't be placed
if (wordCount != placedWords)
{
fprintf(stderr, "Error: %u out of %u were placed\n", placedWords, wordCount);
}
else
{
startGame(wordSalad, SALAD_SIZE, words, placedWords, 1024);
}
} }
else else
{ {
+1 -1
View File
@@ -17,7 +17,7 @@ wordsalad_initial:
# -------------------------- # --------------------------
all: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a all: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS) $(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)
main.o: main.c main.o: main.c
$(CC) -c $(CFLAGS) main.c $(CC) -c $(CFLAGS) main.c
Binary file not shown.