// // example of using command-line arguments: // program to sum its arguments, assumed to be numeric (possibly // floating-point) // #include #include // has atof(), EXIT_SUCCESS, // EXIT_FAILURE, exit() int main(int argc, char *argv[]) { if (argc <= 1) { cout << "Usage: sumpgm value1 value2... \n"; exit(EXIT_FAILURE); // bail out } double sum; for(int i = 1; i < argc; ++i) sum = sum + (atof(argv[i])); cout << "Sum: " << sum << endl; return EXIT_SUCCESS; }