Switch statement

This commit is contained in:
call-cc 2020-06-02 21:36:45 -04:00
parent 9c7fec7479
commit 8adf3476da
1 changed files with 10 additions and 12 deletions

View File

@ -7,23 +7,21 @@ main(int argc, char *argv[])
{ {
int sig = 0; int sig = 0;
pid_t pid; pid_t pid;
switch(argc)
if(argc == 2)
{ {
case 2:
sig = 15; sig = 15;
pid = atoi(argv[1]); pid = atoi(argv[1]);
} break;
else if(argc == 3) case 3:
{
sig = abs(atoi(argv[1])); sig = abs(atoi(argv[1]));
pid = abs(atoi(argv[2])); pid = abs(atoi(argv[2]));
printf("Here 2\n"); puts("Here 2");
break;
default:
} fprintf(stderr, "Specify who to kill\n");
else return 1;
{
printf("Specify who to kill\n %i",argc);
} }
kill(pid,sig); kill(pid,sig);
return 0;
} }