C: Anyway to load parameters into a system() call

后端 未结 2 597
故里飘歌
故里飘歌 2020-12-10 09:58

Is it possible to put arguments in a systems call?

something like

system(\"rm %s %s\", string1, string2)
2条回答
  •  星月不相逢
    2020-12-10 10:08

    Try this:

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

提交回复
热议问题