#include #include using namespace std; #include // ---------------------------------------------- // description of possible arguments // that can be used in // - short format : -m 1 // - or long format : --method=1 // ---------------------------------------------- static struct option long_options[] = { {"method", required_argument, 0, 'm'}, {"alpha", required_argument, 0, 'a'}, {"message", required_argument, 0, 's'}, {"verbose", no_argument, 0, 'v'}, {0,0,0,0} }; // ---------------------------------------------- // Definition of a structure that will gather the // parameters of the program // ---------------------------------------------- typedef struct { int method; float alpha; char *message; bool verbose; } Parameters; Parameters params; // ---------------------------------------------- // main function // ---------------------------------------------- int main(int argc, char *argv[]) { params.verbose = false; if (argc <= 3) { cerr << "the program needs at least 3 arguments" << endl; cerr << argv[0] << " method alpha message" << endl; exit(EXIT_FAILURE); } cout << "program's name = " << argv[0] << endl; for (int i=1; i