同様の答えを探しましたが、私が試したことは何もありません。word
問題があります。void 関数を呼び出して値を変更したいのですがinit()
、単語を印刷しても機能しません。
これに何時間も費やしてきたので、助けていただければ幸いです。
int main(void)
{
char word[MAX_WORD_LEN + 1];
unsigned wrongGuesses = 0;
int guessedLetters[ALPHABET_SIZE] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
init(&word);
printf("%s", word);
displayWord(word, guessedLetters);
guessLetter(word, guessedLetters);
return EXIT_SUCCESS;
}
void init(char* word)
{
int randValue;
char* randWord;
const char* words[NUM_WORDS] = {
"array", "auto", "break", "case", "cast",
"character", "comment", "compiler", "constant", "continue",
"default", "double", "dynamic", "else", "enum",
"expression", "extern", "file", "float", "function",
"goto", "heap", "identifier", "library", "linker",
"long", "macro", "operand", "operator", "pointer",
"prototype", "recursion", "register", "return", "short",
"signed", "sizeof", "stack", "statement", "static",
"string", "struct", "switch", "typedef", "union",
"unsigned", "variable", "void", "volatile", "while"
};
int seed;
seed = (time(NULL));
srand(seed);
randValue = rand() % NUM_WORDS;
randWord = words[randValue];
printf("%s", randWord);
*word = randWord;
}