# include # include # include int main ( int argc, char *argv[] ) { char arg1[81]; char arg2[81]; char arg3[81]; int i; printf ( "\n" ); printf ( " This program expects 4 command line arguments.\n", argc ); printf ( " It will prompt the user to input the missing ones.\n" ); printf ( "\n" ); printf ( " Number of command line arguments entered was %d\n", argc ); printf ( "\n" ); for ( i = 0; i < argc; i++ ) { printf ( " ARGV[%d] = \"%s\"\n", i, argv[i] ); } printf ( "\n" ); printf ( " Do we need to ask the user for missing arguments?\n" ); printf ( "\n" ); // // Did we get argument #1? // if ( argc < 2 ) { printf ( "Enter missing argument #1: " ); scanf ( "%s", arg1 ); } else { strcpy ( arg1, argv[1] ); } // // Did we get argument #2? // if ( argc < 3 ) { printf ( "Enter missing argument #2: " ); scanf ( "%s", arg2 ); } else { strcpy ( arg2, argv[2] ); } // // Did we get argument #3? // if ( argc < 4 ) { printf ( "Enter missing argument #3: " ); scanf ( "%s", arg3 ); } else { strcpy ( arg3, argv[3] ); } printf ( "\n" ); printf ( " Arguments retrieved from command line or user:\n" ); printf ( "\n" ); printf ( " Argument #1 is \"%s\".\n", arg1 ); printf ( " Argument #2 is \"%s\".\n", arg2 ); printf ( " Argument #3 is \"%s\".\n", arg3 ); return 0; }