C++ 文本读写

来源:互联网 发布:java string转数字类型 编辑:程序博客网 时间:2024/05/20 07:33

 

C++ 文本读写


C++文本读写保存 如果是中文 用wofstream 宽字保存 中文字

竟然不可以

原来 是要用一个local 本地环境才可以的

代码如下:

#include "stdafx.h"
#include <fstream>
//#include <>
int _tmain(int argc, _TCHAR* argv[])
{
    std::locale::global(std::locale(""));

    wchar_t a[140]= L"中中";
    std::wifstream f;
    f.open(L"1.txt");
    //f.write(a,10);
    f.read(a,140);

   
    f.close();
    //getchar();
    return 0;
}
原创粉丝点击