Merge remote-tracking branch 'origin/main'
# Conflicts: # Start_Windows/game.c # Start_Windows/input.c
This commit is contained in:
commit
1eca104cd9
@ -22,7 +22,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
for (unsigned int j = 0; j < searchFieldLen; ++j)
|
||||
{
|
||||
salad[i][j] = EMPTY_CHAR;
|
||||
salad[i][j] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
if (salad[i][j] == EMPTY_CHAR)
|
||||
{
|
||||
salad[i][j] = 'A' + (rand() % 26);
|
||||
salad[i][j] = 'A' + rand() % 26;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Start_Windows/game.o
Normal file
BIN
Start_Windows/game.o
Normal file
Binary file not shown.
@ -1,39 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include "input.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAX_WORD_LEN 100
|
||||
|
||||
void capitalletters(char *str) {
|
||||
void capitalletters(char *str){
|
||||
while (*str) {
|
||||
*str = toupper((unsigned char)*str);
|
||||
*str = toupper((unsigned char) *str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Liest Wörter aus Datei und speichert sie sicher im Array
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
char buffer[1024]; // größerer Puffer für ganze Zeile
|
||||
char buffer[MAX_WORD_LEN];
|
||||
unsigned int count_word = 0;
|
||||
|
||||
|
||||
while (count_word < maxWordCount && fgets(buffer, sizeof(buffer), file) != NULL)
|
||||
{
|
||||
// Zeilenumbruch entfernen
|
||||
buffer[strcspn(buffer, "\r\n")] = '\0';
|
||||
|
||||
// Zerlege Zeile in Wörter anhand von Leerzeichen, Komma und Semikolon
|
||||
char *token = strtok(buffer, " ,;");
|
||||
|
||||
while (token != NULL && count_word < maxWordCount)
|
||||
// Zeilenumbruch manuell entfernen
|
||||
for (int i = 0; i < MAX_WORD_LEN; i++)
|
||||
{
|
||||
capitalletters(token); // Großschreiben
|
||||
strncpy(words[count_word], token, MAX_WORD_LEN - 1);
|
||||
words[count_word][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung
|
||||
count_word++;
|
||||
|
||||
token = strtok(NULL, " ,;");
|
||||
if (buffer[i] == '\n' || buffer[i] == '\r')
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
capitalletters(buffer);
|
||||
|
||||
// Sicheres Kopieren in das Zielarray
|
||||
strncpy(words[count_word], buffer, MAX_WORD_LEN - 1);
|
||||
words[count_word][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung sicherstellen
|
||||
|
||||
count_word++;
|
||||
}
|
||||
|
||||
return count_word;
|
||||
}
|
||||
BIN
Start_Windows/input.o
Normal file
BIN
Start_Windows/input.o
Normal file
Binary file not shown.
@ -36,16 +36,10 @@ int main(int argc, char *argv[])
|
||||
// Create the word salad by placing words into grid
|
||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||
|
||||
// TODO:
|
||||
// Check if all words were successfully placed
|
||||
// Start the game if successful
|
||||
// error message if some words couldn't be placed
|
||||
|
||||
|
||||
|
||||
if (placedWords == wordCount)
|
||||
{
|
||||
// Start the game
|
||||
// Start the game if successful
|
||||
unsigned int windowSize = 900; //FRAGE: Programm so programmieren, dass man das weglassen kann
|
||||
startGame(wordSalad, SALAD_SIZE, words, wordCount, windowSize);
|
||||
}
|
||||
@ -56,7 +50,6 @@ int main(int argc, char *argv[])
|
||||
exitCode = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
BIN
Start_Windows/runTests.exe
Normal file
BIN
Start_Windows/runTests.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user