I'm having a little trouble understanding how this piece of code for beginners works. The program simply lets you know if you've typed the same word twice, but I can't for the life of me figure out how it decides which word to assign to string a and then to string b. Does it simply read through all the words that have been entered in order?
1 2 3 4 5 6 7 8
{
string a = " ";
string b;
while (cin>>b) {
if (a == b)
cout << "repeated word: " << b << '\n';
a = b;
}