2
我試圖將字符串轉換爲xmlChar。編譯器說沒有合適的從const字符串到xmlChar的轉換函數存在。這是代碼的樣子:如何將字符串轉換爲xmlChar
bool ClassName::openFile(const String& ZipFile)
{
//convert
const xmlChar *temp = (const xmlChar)ZipFile; //ZipFile has an error here. ZipFile is path and filename
...
}
任何想法?我GOOGLE了它,人們從xmlChar轉換爲字符串,但不是這個方向。
可能'常量XMLCHAR * TEMP =(常量XMLCHAR *)(ZipFile.c_str());' – 2014-11-05 19:41:48
用C風格的類型轉換和C++是在爲因爲貧窮的編碼風格皺起眉頭它是缺陷的來源。我懷疑你想要做一些像'const xmlChar * temp =(const xmlChar *)ZipFile.c_str();'?看看[如何將std :: string轉換爲const char或char](http://stackoverflow.com/questions/347949/how-to-convert-a-stdstring-to-const-char-or-char) – 2014-11-05 19:42:55
除非你提供String和xmlChar的定義,否則這是不可能的。 – antred 2014-11-05 20:12:16