Basically I have made a code that generates only one response, I have collected around 100 responses from my friend, and the whole idea is to get a different response every time, doesn't matter what question is asked.
I would greatly appreciate any help to make this, because my friends responses are just hillarious
I am feeling free to ask mate. But I don't understand how to add the extra rows with text e.g random responses, so every time I run the code the answer is different. Thanks for helping in advance.
The key to what deathslice posted are lines 11 and 29.
Line 11 is an array of four strings each containing one word.
Line 29 chooses one of those words at random. BTW, the subscript is incorrect. It should not add 1. The entries in the array are 0-3. rand() % 4 will return a number between 0 and 3.
If you want to extend the list of words, simply extend the initializer list at line 11. And change the modulus at line 29 to be the number of entries in the list.
It's poor style to hard code the number of entries in the array as deathslice did in line 29. It's better to define a constant which contains the number of words.
The only reason I did i<1 is to guarantee only one response. So, once word receives a random entry, the loops stop and output the random entry(when I was modifying the code I kept getting multiple random entries and I assumed that the OP only wanted one witty response.). BTW thanks for the response and you're right it's bad practice to hard code anything since you always have to assume that the user before and after will be different and will create a different response.
I mean it is not supposed to have custom tailored answer to particular questions, it should just generate 100 witty responses, no matter the question, and they shouldn't be the same. ELI5, I am terrible with C++
Look at line 26 in your OP. The robot will only display a random response if you enter exactly "you?". You enter anything else, any the robot won;t say anything.
If you want the response to be random and different each time, then I guess you would have to check if the response elicited by the robot hasn't been outputted before and discard it if has.
Are you referring to generating random responses in general? Or are you referring to making sure the response is different each time?
If you were referring to generating random responses in general, you might google "eliza code".
If you were referring to making sure each response was unique, I would suggest loading your possible responses into a std::vector<string>. When you use a response, erase it from the vector.