输出'wchar_t *'到'ofstream' [英] Outputting 'wchar_t*' to an 'ofstream'

查看:585
本文介绍了输出'wchar_t *'到'ofstream'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过我已经声明的两个指针将文本输出到文件:

I want to output a text to a file via two pointers that I have declared:

wchar_t   *Col1="dsffsd", *Col2="sdfsf";

这是我试过的:

std::ofstream fout;
fout.open(NativeDatabasePathHist);
fout<<"testing";
fout<<" "<<Col1<<" "<<Col2;
fout.close();

这里是我得到的:

测试113 113

为什么当我打印 Col1 Col2 ,我得到数字而不是字符串?

Why is it that when I print Col1 and Col2, I am getting numbers instead of strings?

推荐答案

首先,使用 std :: wofstream 而不是 std :: ofstream

此外,在文本字符串上使用 L 前缀表示您的文本宽字符

Also, use the L prefix on your text string to indicate that your text is wide character text:

wchar_t   *Col1=L"dsffsd"

这篇关于输出'wchar_t *'到'ofstream'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆