Reputation: 1
so i have this code
char processName[50] = {0}; // init all to 0
printf("Enter the process to kill: ");
scanf("%s", processName); // read and format into the str buffer
printf("Attempting to kill %s\n", processName); // print buffer
system("killall %s", processName);
put this causes the error "too many arguments to function 'system'"
Upvotes: 0
Views: 116
Reputation: 81389
The function system
takes a single argument, the command to execute. You will have to create a temporary string to build such command.
char command[1024] = {};
sprintf(command, "killall %s", processName);
system(command);
Upvotes: 3