警告:使用dprintf时格式未知的转换类型字符'"'

mic*_*ael 7 c

我得到这个编译器(gcc 4.5)警告:

Formatter.cpp:23: warning: unknown conversion type character ‘"’ in format
Run Code Online (Sandbox Code Playgroud)

这是第23行的代码:

dprintf (fd, "<svg width=\"100%\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">");
Run Code Online (Sandbox Code Playgroud)

有人能发现我做错了什么以及导致警告的原因是什么?

Ale*_*ler 14

您需要转义所有出现的%- printf函数系列将它们视为格式说明符并尝试解析下一个字符(例如,如%s).你通过加倍(%%)逃脱它们.