2011-08-05 57 views
1

我試圖做一個字符串編譯錯誤

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

我對着下面的編譯錯誤

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

任何人都可以點我的問題嗎?

回答

8

這部分

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

應該

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

一個反斜槓應寫爲\\和報價是\",所以你需要\\\"爲了得到\"

或者,如果你打算它只是"然後使用

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

無關獎金:的C++ 0x具有raw string literals

2

你有一個額外的反斜槓這裏:

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

它應該閱讀:

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

非常感謝對你也是。 – vaibhav3002