From c564873ed93000687ae248e3811ded95d443bfb4 Mon Sep 17 00:00:00 2001 From: Ivaylo Ivanov Date: Wed, 10 Oct 2018 15:49:24 +0200 Subject: [PATCH] Fix a bug where the program doesn't read the arguments --- mygrep/mygrep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mygrep/mygrep.c b/mygrep/mygrep.c index 0fadde9..4283678 100644 --- a/mygrep/mygrep.c +++ b/mygrep/mygrep.c @@ -1,4 +1,4 @@ -#define _GNU_SOURCE // in order for strcasestr to work +#define _GNU_SOURCE ///< in order for strcasestr to work #include #include #include @@ -15,10 +15,10 @@ int main(int argc, char *argv[]) { char *ofile = NULL; char *keyword = NULL; char *filename = NULL; - int c = getopt(argc, argv, "io:h"); ///< Get the options + int c; /// Process the options - while(c != -1) { + while((c = getopt(argc, argv, "io:h")) != -1) { switch(c) { case 'i': iflag = 1;