2011-12-09 97 views
2

系統()我有一個C++程序
我打電話ImageMagick command通過system();功能
它對於一些簡單的命令
但工作時,我呼籲這個命令警告:在C++

sprintf(command, "convert -threshold 25% f1/file%.3d.png f2/file%.3d.png", num,num); 
system(command); 

其給我警告說

warning: format ‘% f’ expects type ‘double’, but argument 3 has type ‘int’ 

我知道是因爲%在命令25 % f 1是具有不同的含義
請幫我...

回答

6

你必須寫25%%,而不是25%.逃脫「%」的標誌。

+0

非常感謝兄弟 – Wazzzy

3

使用%%,如果你需要包括%字符:

sprintf(command, "convert -threshold 25%% f1/file%.3d.png f2/file%.3d.png", num,num); 
+0

非常感謝 – Wazzzy

2

爲了獲得文字百分號一個需要寫%%,即你的情況:

sprintf(command, "convert -threshold 25%% f1/file%.3d.png f2/file%.3d.png", num,num);