I using only the main function I am trying to input strings into different variables while in a loop. Problem is after I 'Ctrl+z' the program returns 0 and closes
int main()
{
vector<string>words;
for(string disliked; cin>>disliked;)
words.push_back(disliked);
cout<< words.size()<<endl;//everything after this doesn't work
for (string inputz;cin>>inputz;)//added this line to allow user inputz
for(int i=0; i<words.size();++i)
{ if(words[i]==inputz)//changed apple to inputz
cout<<"***\n";
else
cout<<words[i]<<endl;
};
}
Ctrl-z is the way to indicate "end-of-file" from the terminal in Windows. Once you've indicated that cin has reached the eof, then you can't read any more from it until you reset the stream state with cin.clear(). Put it after the first loop.