// stringCompareDemo.cpp
// Demonstrates lexicographical comparison
// of two strings.

#include <iostream>
#include <string>

/*
 * Displays result of lexicographical string
 * comparison for two strings entered as
 * command-line arguments.
 *
 * Command-line arguments:
 *   argv[0] - filename of this program's executable file.
 *   argv[1] - one of two strings to be compared.
 *   argv[2] - the other string to be compared.
 */
int main(int argc, char** argv)
{
   if ( argc < 3 )  {
      cout << "This program will compare any two strings "
              << "entered as command-line arguments." << endl;
      return 0;
   }  // if

   string word1 = argv[1];
   string word2 = argv[2];

   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