Random Shuffle and Vector Elements

hello,
I am a beginner in C++. I am trying to make a code that involves a string vector randomly selecting 1 to 3 elements from another string vector and then shuffling them such that:
Enter word: alpha bravo charlie delta
Result: plahdatlea (alpha and delta)

The user should then be able to type in the correct words which are stored in memory.

As I have said, I am still a beginner there are many things I dont know.

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
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	srand(time(0));

	string input;
	vector<string>animals;

	cout << "Enter At Least 5 Animals: ";

	getline(cin, input);

	animals.push_back(input);
        vector<string>selection; // This must be the vector that takes rand()%3
	
	random_shuffle(selection.begin(), selection.end());

	for (int i = 0; i < selection.size(); ++i) cout << selection[i];

	return 0;
}


PS: For some reason random_shuffle() is not working and the out put is unchanged.
Topic archived. No new replies allowed.