Program to find a Greatest String: C - Program:
Write a program find largest string by c program.
int main( int argc, char *argv[] )
{
if( argc < 2 )
{
cerr << "Usage: strngmax string1 [string2 ...]\n";
return 1;
}
String theGreatestString( argv[1] );
int positionOfTheGreatestString = 1;
int nextArg = 2;
while( nextArg < argc )
{
String argListString ( argv[nextArg++] );
if ( argListString > theGreatestString )
{
theGreatestString = argListString;
positionOfTheGreatestString = nextArg - 1;
}
}
cout << theGreatestString << endl;
return positionOfTheGreatestString;
}