// stringCompareDemoC.cpp
// Demonstrates lexicographical comparison
// of two C-strings.

#include "textUtility2.h"    // includes <iostream>

/*
 * 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

   if ( compare(argv[1], argv[2]) < 0 )
      cout << "\"" <<  argv[1] << "\" precedes \""
                      << argv[2] << "\"." << endl;
   else if ( compare(argv[1], argv[2]) > 0 )
      cout << "\"" <<  argv[2] << "\" precedes \""
                      << argv[1] << "\"." << endl;
   else  //  compare(argv[1], argv[2]) == 0
      cout << "\"" <<  argv[1] << "\" equals \""
                      << argv[2] << "\"." << endl;

   return 0;
}  // function main