Browse Source

clean up word_selector

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
96f7a2f77a
  1. 7
      src/main/c/Hangman/word_selector.c
  2. 4
      src/main/c/Hangman/word_selector.h

7
src/main/c/Hangman/word_selector.c

@ -1,8 +1,7 @@
#include "word_selector.h"
#include "playHangman.h"
// easy words
const char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
"apple",
"world",
"banana",
@ -26,7 +25,7 @@ const char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
};
// hard words
const char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
"database",
"programming",
"mountain",
@ -49,7 +48,7 @@ const char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
"quarter"
};
const char* selectRandomWord(int difficulty) {
char* selectRandomWord(int difficulty) {
// pick a random number and assign it to index of wordsList_easy array
srand((unsigned int)time(NULL));

4
src/main/c/Hangman/word_selector.h

@ -9,4 +9,8 @@
#define MAX_WORD_LENGTH 20
#define NUM_WORDS 20
char* selectRandomWord();
char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1];
char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1];
#endif //PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H
Loading…
Cancel
Save