diff --git a/ex-1/main.c b/ex-1/main.c index 293e052..112fd23 100644 --- a/ex-1/main.c +++ b/ex-1/main.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -15,12 +16,24 @@ * distribution. */ int main(int argc, char** argv) { + size_t samples = 50000; + + /* Process CLI arguments */ + for (size_t i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-n")) samples = atol(argv[++i]); + else { + fprintf(stderr, "Usage: %s -[hn]\n", argv[0]); + fprintf(stderr, "\t-h\tShow this message.\n"); + fprintf(stderr, "\t-n N\tThe size of sample to generate. (default: 50000)\n"); + return EXIT_FAILURE; + } + } + // initialize an RNG gsl_rng_env_setup(); gsl_rng *r = gsl_rng_alloc(gsl_rng_default); // prepare histogram - size_t samples = 50000; double* sample = calloc(samples, sizeof(double)); double min = -10; double max = 10;