commit 8adf3476da95d40bdd590cccabb1f29d50f41091 parent 9c7fec74799adad5e38cb42dfb476c3b5d8cbd6e Author: call-cc <callcc@vxempire.xyz> Date: Tue, 2 Jun 2020 21:36:45 -0400 Switch statement Diffstat:
M | src/kill.c | | | 22 | ++++++++++------------ |
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git 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; }