forked from schroederen/info2Praktikum-Wortsalat
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e20bf82c19 | ||
|
|
1ed03a3444 | ||
|
|
6b435cf82d |
@@ -1,9 +1,9 @@
|
||||
CC = gcc
|
||||
CFLAGS = -g -Wall -I$(raylibfolder)
|
||||
CFLAGS = -g -Wall
|
||||
LDFLAGS = -lGL -lX11 -lm
|
||||
BINARIES = ./linux
|
||||
|
||||
raylib_folder = ./raylib
|
||||
raylibfolder = ./raylib
|
||||
unityfolder = ./unity
|
||||
|
||||
# --------------------------
|
||||
@@ -28,7 +28,7 @@ game.o: game.c
|
||||
$(CC) $(CFLAGS) -c game.c
|
||||
|
||||
graphicalGame.o: graphicalGame.c
|
||||
$(CC) $(CFLAGS) -c graphicalGame.c
|
||||
$(CC) $(CFLAGS) -I$(raylibfolder) -c graphicalGame.c
|
||||
|
||||
# --------------------------
|
||||
# Unit Tests
|
||||
|
||||
+1
-33
@@ -4,41 +4,9 @@
|
||||
|
||||
// TODO:
|
||||
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
||||
/**
|
||||
* @param file Zeiger auf die geöffnete Datei
|
||||
* @param words 2D-Array zum Speichern der Wörter
|
||||
* @param maxWordCount Maximale Anzahl von Wörtern, die eingelesen werden sollen
|
||||
* @return Anzahl der eingelesenen Wörter
|
||||
*/
|
||||
|
||||
// Read words from file and store in 'words' array
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
if (file == NULL || words == NULL || maxWordCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wordCount = 0;
|
||||
char line[MAX_LINE_LEN];
|
||||
|
||||
// Zeilen einlesen
|
||||
while (wordCount < maxWordCount && fgets(line, MAX_LINE_LEN, file) != NULL) {
|
||||
// Zeile in Wörter aufteilen (Trennzeichen: Leerzeichen, Komma, Semikolon, Newline)
|
||||
char *token = strtok(line, " ,;\t\n\r");
|
||||
|
||||
while (token != NULL && wordCount < maxWordCount) {
|
||||
// Prüfen ob Token nicht leer ist
|
||||
if (strlen(token) > 0 && strlen(token) < MAX_WORD_LEN) {
|
||||
// Wort kopieren und in Großbuchstaben umwandeln
|
||||
strcpy(words[wordCount], token);
|
||||
for (int i = 0; words[wordCount][i] != '\0'; i++) {
|
||||
words[wordCount][i] = toupper((unsigned char)words[wordCount][i]);
|
||||
}
|
||||
wordCount++;
|
||||
}
|
||||
// Nächstes Wort
|
||||
token = strtok(NULL, " ,;\t\n\r");
|
||||
}
|
||||
}
|
||||
|
||||
return wordCount;
|
||||
}
|
||||
Binary file not shown.
+2
-2
@@ -4,7 +4,7 @@ LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -f
|
||||
ARCH := $(shell uname -m)
|
||||
BINARIES = ./macos-$(ARCH)
|
||||
|
||||
raylib_folder = ./raylib
|
||||
raylibfolder = ./raylib
|
||||
unityfolder = ./unity
|
||||
|
||||
# --------------------------
|
||||
@@ -43,4 +43,4 @@ test: input.o game.o unit_tests.c $(BINARIES)/libunity.a
|
||||
# Clean
|
||||
# --------------------------
|
||||
clean:
|
||||
rm -f *.o wordsalad
|
||||
rm -f *.o wordsalad $(TEST_BIN)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,9 +1,9 @@
|
||||
CC = gcc
|
||||
CFLAGS = -g -Wall -I$(raylibfolder)
|
||||
CFLAGS = -g -Wall
|
||||
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
||||
BINARIES = ./windows
|
||||
|
||||
raylib_folder = ./raylib
|
||||
raylibfolder = ./raylib
|
||||
unityfolder = ./unity
|
||||
|
||||
# --------------------------
|
||||
@@ -12,7 +12,6 @@ unityfolder = ./unity
|
||||
wordsalad_initial:
|
||||
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||
|
||||
|
||||
# --------------------------
|
||||
# Normales Spiel bauen
|
||||
# --------------------------
|
||||
@@ -29,7 +28,7 @@ game.o: game.c
|
||||
$(CC) -c $(CFLAGS) game.c
|
||||
|
||||
graphicalGame.o: graphicalGame.c
|
||||
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
|
||||
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
|
||||
|
||||
# --------------------------
|
||||
# Unit Tests
|
||||
|
||||
Reference in New Issue
Block a user