Beispiel #1
0
/*
 * Play wheel of fortune using words loaded from a file.
 */
int main() {
    // Initialize wheel
    initialize_wheel();

    // Select random seed
    srandom(RANDOM_SEED);

    // Load words
    int numwords = 0;
    item_t *list_head = load_words(WORDS_FILE, &numwords);
    if (NULL == list_head) {
        printf("Failed to load words from %s\n", WORDS_FILE);
        return 1;
    }

    // Select a word
    char *word = choose_random_word(list_head, numwords);
    if (NULL == word) {
        printf("Failed to choose a word\n");
        return 1;
    }

    // Play game
    int winner = play_round(word);
    printf("Player %d solved the puzzle!\n", winner);

    // Clean up
    free_words(list_head);
}
int main() {
    srandom(time(NULL));
    int num_words = 0;
    wordnode *words = load_words("/usr/share/dict/words", &num_words);
    if (num_words == 0) {
        printf("Didn't load any words?!\n");
        return 0;
    }
    printf("Words loaded: %d\n", num_words);
    const char *word = choose_random_word(words, num_words);
    printf("The random word is: %s\n", word);
    one_game(word);
    free_words(words);
    //printf("Evereyone is free!\n");
    return 0;
}