From 800874873c93403a83fffbd8493b8e7f154c21fb Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 19 Oct 2017 12:03:02 +0000 Subject: pasad: Read N, L and r from arguments --- broccoli/src/pasad.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/broccoli/src/pasad.c b/broccoli/src/pasad.c index 1bb0e26..c506410 100644 --- a/broccoli/src/pasad.c +++ b/broccoli/src/pasad.c @@ -13,7 +13,7 @@ Modified by Robin Krahl , Group 3: - Write sensor readings and distance to text files - - Take the arguments N, L, r from argc (TODO) + - Take the arguments N, L, r from argc - Formatting */ @@ -23,12 +23,23 @@ #include #include "midbro.h" -int main() +int main(int argc, char **argv) { clock_t begin; - int N=1000,L=500,r=18,l=0; + int l=0; double t=30; + if (argc != 4) { + fprintf(stderr, "Usage: %s N L r\n", argv[0]); + fprintf(stderr, " Example values: N = 1000, L = 500, r = 18\n"); + fprintf(stderr, "Wrong argument count. Aborting.\n"); + return 1; + } + + int N = atoi(argv[1]); + int L = atoi(argv[2]); + int r = atoi(argv[3]); + FILE *file_sensor = fopen("sensor.dat", "w"); FILE *file_distance = fopen("distance.dat", "w"); -- cgit v1.2.3