home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c063 / 3.ddi / CLASSEXM.ZIP / STRNGMAX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  1.1 KB  |  44 lines

  1. #if !defined( __STRNG_H )
  2. #include <strng.h>
  3. #endif  // __STRNG_H
  4.  
  5. #ifndef __IOSTREAM_H
  6. #include <iostream.h>
  7. #endif
  8.  
  9. //
  10. // Determines the maximum string using the ASCII collating sequence to 
  11. // define rank.  A string is defined to be greater than another if the
  12. // ASCII values of its characters are greater than the values of the other
  13. // string.  For example,
  14. //
  15. // strngmax Alpha Beta Charlie
  16. //
  17. // would print Charlie to stdout and return 3.
  18. //
  19. int main( int argc, char *argv[] )
  20. {
  21.     if( argc < 2 )
  22.         {
  23.         cerr << "Usage:  strngmax string1 [string2 ...]\n";
  24.         return 1;
  25.         }
  26.  
  27.     String theGreatestString( argv[1] );
  28.     int positionOfTheGreatestString = 1;
  29.     int nextArg = 2;
  30.  
  31.     while( nextArg < argc )
  32.         {
  33.         String argListString ( argv[nextArg++] );
  34.         if ( argListString > theGreatestString )
  35.             {
  36.             theGreatestString = argListString;
  37.             positionOfTheGreatestString = nextArg - 1;
  38.             }
  39.         }
  40.  
  41.     cout << theGreatestString << endl;
  42.     return positionOfTheGreatestString;
  43. }
  44.