home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 8.img / CLASSEXM.ZIP / STRNGMAX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  2.5 KB  |  101 lines

  1. //
  2. // This file contains proprietary information of Borland International.
  3. // Copying or reproduction without prior written approval is prohibited.
  4. //
  5. // Copyright (c) 1990
  6. // Borland International
  7. // 1800 Scotts Valley Dr.
  8. // Scotts Valley, CA 95066
  9. // (408) 438-8400
  10. //
  11.  
  12. // Contents ----------------------------------------------------------------
  13. //
  14. //      main
  15. //
  16. // Description
  17. //
  18. //      Contains a simple example program for class String.
  19. //
  20. // End ---------------------------------------------------------------------
  21.  
  22. // Interface Dependencies ---------------------------------------------------
  23.  
  24. // None
  25.  
  26. // End Interface Dependencies ------------------------------------------------
  27.  
  28. // Implementation Dependencies ----------------------------------------------
  29.  
  30. #ifndef __IOSTREAM_H
  31. #include <iostream.h>
  32. #define __IOSTREAM_H
  33. #endif
  34.  
  35. #ifndef __STRNG_H
  36. #include <strng.h>
  37. #endif
  38.  
  39. // End Implementation Dependencies -------------------------------------------
  40.  
  41.  
  42. // Function //
  43.  
  44. int main( int argc, char *argv[] )
  45.  
  46. // Summary -----------------------------------------------------------------
  47. //
  48. //      Illustrates a use of the String class.  Displays the alphabetically
  49. //      last string out of the given command line and returns the position
  50. //      of that string.
  51. //
  52. //      Usage:  strngmax string1 [string2 ...]
  53. //
  54. // Parameters
  55. //
  56. //      argc
  57. //
  58. //      The number of arguments passed on the command line.  There must
  59. //      be at least 1 argument other than the command name.
  60. //
  61. //      argv
  62. //
  63. //      A vector of character strings which are the arguments to the
  64. //      command line.
  65. //
  66. // Return Value
  67. //
  68. //     maxPosition
  69. //
  70. //     The position on the command line of the last string.  Returns
  71. //     1 if an error occurs.
  72. //
  73. // End ---------------------------------------------------------------------
  74. {
  75.     if ( argc < 2 )
  76.     {
  77.         cerr << "Usage:  strngmax string1 [string2 ...]\n";
  78.         return 1;
  79.     }
  80.  
  81.     String theLargestString( argv[1] );
  82.     int    maxPosition = 1;
  83.     int nextArg = 2;
  84.  
  85.     while ( nextArg < argc )
  86.     {
  87.         String argListString ( argv[nextArg++] );
  88.         if ( argListString > theLargestString )
  89.         {
  90.             theLargestString = argListString;
  91.             maxPosition = nextArg - 1;
  92.         }
  93.     } // end while more arguments on the command line.
  94.  
  95.     cout << theLargestString << "\n";
  96.     return maxPosition;
  97. }
  98. // End Function main //
  99.  
  100.  
  101.