aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <guskraro@student.gu.se>2017-10-19 12:03:02 +0000
committerRobin Krahl <guskraro@student.gu.se>2017-10-19 12:03:02 +0000
commit800874873c93403a83fffbd8493b8e7f154c21fb (patch)
tree3b618ba2d0633bf954c2fa7f56733f860490aac0
parentb82dab8827ba9eecf02a1e805b3b9f2e8aed2fb8 (diff)
downloadmidbro-800874873c93403a83fffbd8493b8e7f154c21fb.tar.gz
midbro-800874873c93403a83fffbd8493b8e7f154c21fb.tar.bz2
pasad: Read N, L and r from arguments
-rw-r--r--broccoli/src/pasad.c17
1 files 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 <guskraro@student.gu.se>, 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 <time.h>
#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");