1. strcmp() is a function that compares two strings
2. ! is used to mean not equal to 0 because this function returns 0 when the two strings aren't equal.
3. As explained in the code:
Code:
#include <iostream>
#include <cstring>
int main(int argc, char *argv[])
{
if(!(strcmp(argv[1],"byname") )
{
sortbyname()// you would be sorting by name
}
else
{
sortbysex()// sort it otherwise
}
return 0;
}
the argv[1] is the command line argument so if you were to say (using your first example) "s.exe byname" the program would execute the first if:
Code:
if(!(strcmp(argv[1],"byname") )
{
sortbyname()// you would be sorting by name
}
and would sort it by name. Undersatnd now?
-Devouring One-