From 8adf3476da95d40bdd590cccabb1f29d50f41091 Mon Sep 17 00:00:00 2001 From: call-cc Date: Tue, 2 Jun 2020 21:36:45 -0400 Subject: [PATCH] Switch statement --- src/kill.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/kill.c b/src/kill.c index a18f2a1..819ac19 100644 --- a/src/kill.c +++ b/src/kill.c @@ -7,23 +7,21 @@ main(int argc, char *argv[]) { int sig = 0; pid_t pid; - - if(argc == 2) + switch(argc) { + case 2: sig = 15; pid = atoi(argv[1]); - } - else if(argc == 3) - { + break; + case 3: sig = abs(atoi(argv[1])); pid = abs(atoi(argv[2])); - printf("Here 2\n"); - - - } - else - { - printf("Specify who to kill\n %i",argc); + puts("Here 2"); + break; + default: + fprintf(stderr, "Specify who to kill\n"); + return 1; } kill(pid,sig); + return 0; }