generated from freudenreichan/info2Praktikum-Wortsalat
input filled with logic
This commit is contained in:
parent
099243b5e2
commit
3657ee5ff7
BIN
Start_Windows/game.o
Normal file
BIN
Start_Windows/game.o
Normal file
Binary file not shown.
BIN
Start_Windows/graphicalGame.o
Normal file
BIN
Start_Windows/graphicalGame.o
Normal file
Binary file not shown.
@ -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)
|
||||||
{
|
{
|
||||||
|
// MAX_WORD_LEN 100
|
||||||
|
// MAX_LINE_LEN 1024
|
||||||
|
// *file ist Datei
|
||||||
|
// words ist Array
|
||||||
|
// MAX_WORD_LEN ist maximale Wortlänge
|
||||||
|
// maxWordCount ist maximale Anzahl an Wörtern
|
||||||
|
char puffer[MAX_LINE_LEN];
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
while(fgets(puffer, MAX_LINE_LEN-1, file) != NULL && counter < maxWordCount)
|
||||||
|
{
|
||||||
|
char *parts = strtok(puffer, ",;/n/t. ");
|
||||||
|
|
||||||
|
while(parts != NULL && counter < maxWordCount)
|
||||||
|
{
|
||||||
|
//strncpy(words[counter][MAX_WORD_LEN], puffer, MAX_LINE_LEN-1);
|
||||||
|
//words[counter][MAX_WORD_LEN-1] = "\0";
|
||||||
|
//Großbuchstaben
|
||||||
|
for(int i = 0; i < MAX_WORD_LEN -1 && parts[i] != '\0'; i++)
|
||||||
|
words[counter][i] = toupper(parts[i]);
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
parts = strtok(NULL, ",;/n/t. ");
|
||||||
|
|
||||||
|
}
|
||||||
|
return counter;
|
||||||
}
|
}
|
||||||
BIN
Start_Windows/input.o
Normal file
BIN
Start_Windows/input.o
Normal file
Binary file not shown.
BIN
Start_Windows/main.o
Normal file
BIN
Start_Windows/main.o
Normal file
Binary file not shown.
@ -47,4 +47,4 @@ clean:
|
|||||||
#hier eigene wordsalad kopieren, library rauslassen
|
#hier eigene wordsalad kopieren, library rauslassen
|
||||||
|
|
||||||
wordsalad_myversion: main.o input.o game.o graphicalGame.o $(BINARIES)/libwordsalad.a
|
wordsalad_myversion: main.o input.o game.o graphicalGame.o $(BINARIES)/libwordsalad.a
|
||||||
$(CC) $(CFLAGS) -o wordsalad_myversion main.o input.o game.o graphicalGame.o $(BINARIES)/libwordsalad.a $(LDFLAGS)
|
$(CC) $(CFLAGS) -o wordsalad_myversion main.o input.o game.o graphicalGame.o $(BINARIES)/libwordsalad.a $(LDFLAGS)
|
||||||
Loading…
x
Reference in New Issue
Block a user