我有以下字符串,我需要保持格式,缩进,换行等。任何想法如何做?
char *myXMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<painting>"
" <img src=\"madonna.jpg\" alt=\"Foligno Madonna, by Raphael\"/>"
" <caption>MY_REPLACED_TEXT"
" <date>1511</date>-<date>1512</date>.</caption>"
"</painting>";
printf只提供一个长文本。
答案 0 :(得分:3)
在您认为合适的地方添加"\n"
,例如:
char *myXMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "\n"
"<painting>\n"
" <img src=\"madonna.jpg\" alt=\"Foligno Madonna, by Raphael\"/>" "\n"
" <caption>MY_REPLACED_TEXT\n"
" <date>1511</date>-<date>1512</date>.</caption>\n"
"</painting>\n";