I am trying to randomly display a user input string using c++ but I couldn't find a way to do. Currently I am pre defining some strings
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
const string wordlist[4] = {"hi","hello","what's up","wassup"};
string word = wordlist [rand()%4];
cout<<word;
return 0;
}
What I want is:- I don't want to pre define them. I want the user to type in 4 words and I will display a word from the 4 words given by the user (randomly).