簡體   English   中英

在c中調用外部程序似乎不起作用(空格錯誤)

[英]calling an external program in c doesn't seem to work (error with spaces)

當我編寫此代碼時:

if(number==5) {
    system("start c:\\geek.exe");
}

一切正常,因為路徑中沒有空格。 但是當我寫這樣的東西:

if(number==8) {
    system("start C:\\program files\\LibreOffice 5\\program\\soffice.exe");
}

我收到一條消息,它找不到路徑。

您需要使用雙引號:-

system("start \"C:\\program files\\...\");

我找到了正確的方法:

if(number==8) {
    system("\"C:\\Program Files\\LibreOffice 5\\program\\soffice.exe\"");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM