// command-line arguments // #include int main( int argc, char *argv[]) // argument count and vector (array of strings) { // view: for( int i = 0; i < argc; ++i) printf( "%i: %s\n", i, argv[i]); // process: int p = 0; if( argc > 1) if( argv[1][0] == 'p') p = 1; printf( "p = %i\n", p); } /* sample runs: $ ./a.out a bb cc 0: ./a.out 1: a 2: bb 3: cc p = 0 $ ./a.out p 0: ./a.out 1: p p = 1 */