Name: Anonymous 2011-09-20 10:08
I don´t understand the following code, particularly how the next string is stored into "previous". "cin>>current" just moves words into current. Where is the order to move the next word into previous? Code is from Stroustup:
[code]
int main()
{
string previous = " ";
string current;
while (cin>>current){
if(previous==current)
cout<<"word repetition:"<<current<<'\n';
previous=current;
}
}
[code]
int main()
{
string previous = " ";
string current;
while (cin>>current){
if(previous==current)
cout<<"word repetition:"<<current<<'\n';
previous=current;
}
}