简体   繁体   中英

How to print this string in C

I'm having trouble printing out this string in C

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>";

If I use printf("%c",*myXMLString); I get expected parameter declarator missing. Tried sprintf with similar results.

printf("%s", myXMLString);

is how you print a C-string. %s is the format to be used for priting strings. See the man page of printf for details.

On the other hand, if you could't figure this out yourself, you really need to study a proper textbook or at least a tutorial.

  fprintf(adgfile, "%s", myXMLString);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM