是否可以在系统调用中放入参数?
就像是
system("rm %s %s", string1, string2)
system
函数的原型是:
int system(const char *command);
所以不行。但是,怎么样:
snprintf(buffer, sizeof(buffer), "rm %s %s", target1, target2);
system(buffer);
试试这个:
private:
char command[128];
char temp[10] = {'"','I','P','v','4','"'}; //snprintf();
public:
int SysInfo(){
snprintf(command,sizeof(command), "ipconfig | find %s > save.log",temp);
system(command);
}