#include <iostream>
#include <vector>
usingnamespace std;
int main()
{
string str;
vector<string> datas;
do{
//<---Find the start point of your loop.
cout<<"Enter a string: ";
getline(cin, str);
datas.push_back(str);
while(cout<<"\nRepeat?(yes or no): "&&getline(cin,str)&&(str!="yes" && str!="no"))//Prompt/validate for exit choice.
cout<<"Invalid, answer must be (yes or no)\n";//validate: error prompt
cout<<'\n';
//<---Find the end of your loop.
}while(str=="yes");
cout<<"The strings recorded were: \n";
for(int i=0;i<datas.size();++i)
cout<<datas[i]<<'\n';
cout<<'\n';
cout<<"Press <enter> to exit console: ";
cin.get();
return 0;
}
Enter a string: Hello World
Repeat?(yes or no): intentional
Invalid, answer must be (yes or no)
Repeat?(yes or no): yes
Enter a string: This is a string
Repeat?(yes or no): yes
Enter a string: Good Bye
Repeat?(yes or no): no
The strings recorded were:
Hello World
This is a string
Good Bye
Press <enter> to exit console:
I do not provide direct solutions to specifics, but rather examples that may help lead you to your goal.
The above would prompt a string then validate for continuation and repeat the validation loop if the string entered was not "yes" or "no". It would, then, repeat the procedures if the string was "yes".
Any data in str could end to procedure loop, other than "yes", but the validation loop would prohibit any data other than "yes" and "no".