28 lines
684 B
C
28 lines
684 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "word.h"
|
|
#include "game.h"
|
|
#include "util.h"
|
|
|
|
void load_word(Game *g, char *line) {
|
|
char *token = strtok(line, "|");
|
|
Word *word = &g->words->words[g->words->count];
|
|
word->word = malloc(strlen(token) + 1);
|
|
strcpy(word->word, token);
|
|
|
|
word->synonyms_count = 0;
|
|
while ((token = strtok(NULL, ",")) != NULL) {
|
|
word->synonyms[word->synonyms_count] = malloc(strlen(token) + 1);
|
|
strcpy(word->synonyms[word->synonyms_count], token);
|
|
word->synonyms_count++;
|
|
}
|
|
|
|
g->words->count++;
|
|
}
|
|
|
|
#include "data/words.c"
|
|
void game_load_words(Game *g) {
|
|
parse_multiline_string(g, data_words_txt, &load_word);
|
|
}
|