// Example of passing numeric parameters through command line. v. 10/9/02 // Assumes numeric input. // Reports error if too few args passed. // Echos argv values. #include // for cerr and cout. #include // for atof which converts char arrays to floats. using namespace std; int main( int argc, char *argv[] ) { // Make sure have at least 1 parameter; a floating point precision if ( argc <= 1 ) { cerr << "INVALID USAGE" << endl; cerr << "Usage: prog3 [precision percent]" << endl; return 1; } float precision = atof(argv[1]); cout << "argv[0]: '" << argv[0] << "'" << endl; cout << "argv[1]: '" << argv[1] << "'" << endl; cout << "Specified precision: " << precision << endl; }