//---------------------------------------------------------------- // showargs.cpp // // This program was written to test the 'execve()' function. // It displays the value of the 'argc' argument and the full // list of the command-line arguments, if any were supplied. // // example usage: $ myexec showargs 1 2 3 4 5 // // programmer: ALLAN CRUSE // written on: 10 SEP 2004 //---------------------------------------------------------------- #include // for printf() int main( int argc, char **argv ) { //---------------------------------------------------- // show the number of elements in the argument-vector //---------------------------------------------------- printf( "\n\'%s\': argc=%d \n\n", argv[0], argc ); //--------------------------------------------------- // print each one of that argument-vector's elements //--------------------------------------------------- for (int i = 0; i < argc; i++) printf( "arg %d: \'%s\' \n", i, argv[i] ); printf( "\n" ); }