// stringCompareDemo.cpp
// Demonstrates lexicographical comparison
// of two strings. Displays result of
// lexicographical comparison of two
// strings entered by the user.
#include <iostream>
#include <string>
int main()
{
cout << "This program will compare, lexicographically, "
<< "two words you enter." << endl;
cout << "Enter the first word:>";
string word1;
cin >> word1;
cout << "Enter the first word:>";
string word2;
cin >> word2;
if ( word1 < word2 )
cout << "\"" << word1 << "\" precedes \""
<< word2 << "\"." << endl;
else if ( word1 > word2 )
cout << "\"" << word2 << "\" precedes \""
<< word1 << "\"." << endl;
else // word1 == word2
cout << "\"" << word1 << "\" equals \""
<< word2 << "\"." << endl;
return 0;
} // function main