I need to write code that checks if the user enters the same word twice, and if so, he will display a message about what they did. So far I have had:
#include <iostream> using namespace std; int main(){ string previous = ""; string current = ""; while (cin>>current); { if(current == previous); { cout<<"repeated word"; } previous=current; } }
It compiles, but it does not display a message when the user enters the same word twice.
source share