Input fertig mit Makefile für Input
This commit is contained in:
1 parent
0ad0165c1a
commit
fe390a6f5f
2 files changed
+42
-3
No files matched your search
+33
-3
@@ -6,7 +6,37 @@
|
|||||||
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
||||||
|
|
||||||
// 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){
|
||||||
{
|
|
||||||
|
char lineRead[MAX_LINE_LEN] = {};
|
||||||
|
char *splitters = ",; \n";
|
||||||
|
int wordsRead = 0;
|
||||||
|
|
||||||
|
while(fgets(lineRead,MAX_LINE_LEN,file) != NULL && wordsRead < maxWordCount){
|
||||||
|
char *token = strtok(lineRead, splitters);
|
||||||
|
|
||||||
|
while(token != NULL && wordsRead < maxWordCount){
|
||||||
|
|
||||||
|
strcpy(words[wordsRead],token);
|
||||||
|
//Kleinbuchstaben -> Grossbuchstaben
|
||||||
|
int len = strlen(words[wordsRead]);
|
||||||
|
for(int i = 0; i < len; i++){ //müsste einen kleinbustaben am ende haben
|
||||||
|
if(islower(words[wordsRead][i])){
|
||||||
|
words[wordsRead][i] = toupper(words[wordsRead][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wordsRead++;
|
||||||
|
token = strtok(NULL, splitters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wordsRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,15 @@ codefolder = .
|
|||||||
wordsalad_initial:
|
wordsalad_initial:
|
||||||
$(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
$(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||||
|
|
||||||
|
#--------------
|
||||||
|
# Mein Test
|
||||||
|
#--------------
|
||||||
|
|
||||||
|
my_wordsalad_input: input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a
|
||||||
|
$(CC) $(CFLAGS) -o my_wordsalad_input input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Normales Spiel bauen
|
# Normales Spiel bauen
|
||||||
# --------------------------
|
# --------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user