我試圖使用用戶的輸入被用作將被傳遞到CMD參數...如何將參數從C++程序傳遞給cmd?
我知道,使用CMD從我的節目,我需要用這個:
system("SayStatic.exe hello world");
但是這正是我需要的:
char item[100];
gets(item);
//after getting the input I need to pass it to SayStatic.exe that is the part I dont know
我知道我不能使用sysytem();爲此,但其他像spawnl()或execl()會工作?
爲什麼你就不能使用'系統()'? – 2012-02-25 06:24:54
我需要的參數是一個變量 – user1232148 2012-02-25 06:27:03
不要使用'gets'來輸入,這是一個巨大的漏洞,很容易用於緩衝區溢出。無論如何,C++程序員應該使用'iostream'東西,而不是'cstdio'東西。 – paxdiablo 2012-02-25 07:33:57