/* strcmp.c */ #include #include #include int main( int argc, char *argv[] ) { /* compare argv[1] with "-reverse" */ if ( strcmp( argv[1], "-reverse" ) == 0 ) { printf( "The -reverse flag has been detected!\n" ); } /* another way (style) of writing this: */ if ( !strcmp( argv[1], "-reverse" ) ) { printf( "The -reverse flag has been detected!\n" ); } /* look for -skip */ if ( strcmp( argv[1], "-skip" ) == 0 ) { int N = atoi( argv[2] ); /* atoi() converts alpha (char[]) to int */ printf( "Going to skip every %d characters\n", N ); } return EXIT_SUCCESS; }