2012-05-13 38 views
0

我試圖從文件中使用boost模塊和C++搜索一個單詞,我卡在這錯誤消息:C++加載錯誤:無法將const值類型*(又名常量wchar_t *)轉換爲常量字符*初始化

error: cannot convert 'const value_type* {aka const wchar_t*}' to 'const char*' in initialization 

誤差來源於此行代碼:

const char* file_path = itr->path().filename().c_str(); 

感謝。

+1

不看任何具體,路徑'()'返回一個'wstring',所以'c_str()'返回'常量爲wchar_t *'不是'const char *'。 – chris

回答

3

這是告訴你,你需要這樣的:

const wchar_t* file_path = itr->path().filename().c_str(); 
相關問題