generated from freudenreichan/info2Praktikum-Wortsalat
Finale Version V1
Finale Version V1 Finale Version V1 Finale Version V1 Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
442a5aabed
commit
d3ba3a29e2
@ -25,13 +25,13 @@ static void trim_and_toupper(char*dest, const char*src, int max_len) {
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount) {
|
||||
unsigned int count = 0;
|
||||
char line_buffer[MAX_LINE_LEN];
|
||||
const char* DELIMITERS=",:\n;";
|
||||
const char* DELIMITERS=",:\n; ";
|
||||
while (count < maxWordCount && fgets(line_buffer, MAX_LINE_LEN, file)!= NULL) {
|
||||
char* token = strtok(line_buffer, DELIMITERS);
|
||||
|
||||
while (token != NULL && count < maxWordCount) {
|
||||
trim_and_toupper(words[count], token, MAX_WORD_LEN);
|
||||
if (words[count][0] !='\n'){
|
||||
if (words[count][0] !='\0'){
|
||||
count++;
|
||||
}
|
||||
token = strtok(NULL, DELIMITERS);
|
||||
|
||||
@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
|
||||
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
||||
fclose(file);
|
||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, (const char(*)[MAX_WORD_LEN])words, wordCount);
|
||||
if (placedWords > 0) {
|
||||
if (placedWords == wordCount) {
|
||||
printf("Info: %d Wörter geladen und platziert. Starte speil...\n", placedWords);
|
||||
showWordSalad(wordSalad, SALAD_SIZE);
|
||||
startGame(wordSalad, SALAD_SIZE, words, wordCount,WINDOW_WIDTH);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user