This program supposed to find command line arguments entered on Unix which ends with “.exe”. For some reason it doesn't work. Here is the code:
int main( int argc, char* argv[] )
{
for ( int i = 1; i < argc; i++)
if( findExe( argv[i] ) )
cout << argv[i] << endl;
return 0;
}
bool findExe( char* argument )
{
if ( strlen( argument ) >= 4 )
{
string testExe = ".exe";
string initialWord=argument; //converts c-string to string
string temp( initialWord,( initialWord.size() - 4 ),4 );//creates temp with last four characters from initialWord
if ( !temp.compare(testExe) )
return true;
}
else
return false;
}