int getRandomGenerator()
{
int value = 0;
srand(static_cast<int>(time(0)));
value = 1 + rand() % (10 - 1 + 1);
return value;
}
int stringList()
{
//Calling pre defined words
constint HANGMAN_WORDS = 10;
string name [HANGMAN_WORDS] = { "apple", "orange", "car", "truck", "bicycle", "cat", "dog", "snake", "rock", "sock" };
return 0;
}
I want the generator to randomly pick from the string list so it will be the word that the user has to guess for the game. I tried setting the string = to getRandomGenerator but I just end up getting an error.
If you generate a random number x say, then a randomly selected word would be name[x]. Make sure x is within the range of the name array. i.e. 0 <= x < 10 in your case