C:无论如何将参数加载到system()调用中
是否可以在系统调用中添加参数?
就像是
system("rm %s %s", string1, string2)
system
function的原型是:
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); }