0

所以我有这个代码

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);

放这会导致错误“函数'系统'的参数太多”

4

1 回答 1

3

该函数system接受一个参数,即要执行的命令。您必须创建一个临时字符串来构建这样的命令。

char command[1024] = {};
sprintf(command, "killall %s", processName);
system(command);
于 2012-06-09T20:56:54.053 回答