我想通过我声明的两个指针将文本输出到文件:
wchar_t *Col1="dsffsd", *Col2="sdfsf";
这是我尝试过的:
std::ofstream fout;
fout.open(NativeDatabasePathHist);
fout<<"testing";
fout<<" "<<Col1<<" "<<Col2;
fout.close();
这就是我得到的:
testing 113 113
为什么当我打印 Col1
和 Col2
时,我得到的是数字而不是字符串?
最佳答案
首先,使用 std::wofstream
代替 std::ofstream
。
此外,在您的文本字符串上使用 L
前缀表示您的文本是宽字符文本:
wchar_t *Col1=L"dsffsd"
关于c++ - 将 'wchar_t*' 输出到 'ofstream',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12889405/