vaibhav3002
vaibhav3002

Reputation: 275

Compilation error in C strings

I am trying to make a string

#define TEST_RESULT "<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0/\" xmlns:pv=\"http://www.pv.com/pvns/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"><container id=\"1\" parentID=\\"0\" childCount=\"0\" restricted=\"1\" ><dc:title>VaibhavVideos</dc:title><upnp:class>object.container</upnp:class></container></DIDL-Lite>"

I am facing the following compilation error

error: expected ‘)’ before numeric constant
error: stray ‘\’ in program

Can anybody point me the problem?

Upvotes: 1

Views: 93

Answers (2)

RichieHindle
RichieHindle

Reputation: 281475

You have an extra backslash here:

id=\"1\" parentID=\\"0\"
                  ^

It should read:

id=\"1\" parentID=\"0\"

Upvotes: 2

Armen Tsirunyan
Armen Tsirunyan

Reputation: 132994

This part

...parentID=\\"0\"... 

should be

...parentID=\\\"0\"... 

A single backslash should be written as \\ and quote is \", so you need \\\" in order to get \"

Or if you intended it to be just " then use

...parentID=\"0\"...

Unrelated bonus: C++0x has raw string literals

Upvotes: 8

Related Questions