pass parameter using system command

后端 未结 2 669
迷失自我
迷失自我 2021-01-21 12:28

I have an executable program that runs in several pc\'s in a network. At first it gets the host name (pc-001.. pc-013 etc). Then i need to mount a network drive (server1) on ev

2条回答
  •  时光说笑
    2021-01-21 13:11

    Use the snprintf to construct the command string before you use it:

    char command[128];
    snprintf(command, sizeof(command), "net use x: \\\\server1\\shares /user:%s %s",
             some_username, some_password);
    system(command);
    

提交回复
热议问题