Hangman theme/words

Hello I am trying to make a hangman game where I ask the user to choose between a set of themes and then randomly select a word for the user to solve. However I am not sure how I am suppose to create a txt file that would allow me to do this
I wrote my themes (3) and words associated with each one (8) but I dont know if this is the proper way to write it or if it is how I would be able to display it properly.

sports- baseball soccer basketball hockey golf football lacrosse tennis
animals- dog cat deer fox fish coyote monkey zebra
trees- maple oak cherry hickory apple pine walnut ash
Make 3 vectors of strings to store your words, then prompt the user to select one of them. Shuffle the vector, afterwards pick a random word from the chosen vector.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
        std::vector<std::string> animals = { "dog", "cat", "deer" };
	std::vector<std::string> sports = { "baseball", "soccer", "tennis" };
	std::vector<std::string> trees = { "maple", "oak", "ash" };

	std::cout << "Chose \n 1 - for animals \n 2 - for sports \n 3 - for trees\n";
	int choice;
	std::cin >> choice;
	std::vector<std::string> chosen;

	switch (choice)
	{
	case 1: chosen = animals;
		break;
	case 2: chosen = sports;
		break;
	case 3: chosen = trees;
		break;
	default: 
               {
                 std::cout << "Invalid choice, standard set picked";
                 chosen=animals;
               }
		break;
	}

	std::random_shuffle(chosen.begin(), chosen.end());
	std::random_device chose_word;

	std::string word = chosen[chose_word() % int(chosen.size()-1)];

}
Last edited on
thank you so much !
Topic archived. No new replies allowed.