/// @file /// @brief Task A /// gcc -g -fsanitize=address -std=c11 taskA.c -Imodules -o taskA /// ./taskA -opt1 10 -opt2 1.5 -opt3 X -opt4 lab5 #include "iue-po/cpo.h" // iuepo_get_* #include // printf #include // EXIT_SUCCESS, EXIT_FAILURE /// @todo Implement a main function supporting the following command line arguments: /// -opt1 integer (required) /// -opt2 double (required) /// -opt3 char (optional, default is 'A') /// -opt4 string (optional, default is "empty") int main(int argc, char* argv[]) { /// @todo Parse the command line arguments according to the specification above: /// - have a look at modules/iue-io/cpo.test.h (you can use this as a starting point) /// - If mandatory arguments are missing or cannot be parsed, the program aborts with an error. /// @todo Print all passed command line arguments to the console int opt1; if (iuepo_get_int(argc, argv, "opt1", &opt1, IUEPO_REQUIRED) != EXIT_SUCCESS) return EXIT_FAILURE; double opt2; if (iuepo_get_double(argc, argv, "opt2", &opt2, IUEPO_REQUIRED) != EXIT_SUCCESS) return EXIT_FAILURE; char opt3 = 'A'; if (iuepo_get_char(argc, argv, "opt3", &opt3, IUEPO_OPTIONAL) != EXIT_SUCCESS) return EXIT_FAILURE; char opt4[256] = "empty"; if (iuepo_get_string(argc, argv, "opt4", opt4, sizeof(opt4), IUEPO_OPTIONAL) != EXIT_SUCCESS) return EXIT_FAILURE; printf("'%i'\n", opt1); printf("'%lf'\n", opt2); printf("'%c'\n", opt3); printf("'%s'\n", opt4); return EXIT_SUCCESS; }