c++ std::ifstream

#include <iostream>
#include <plug/plug.h>
using namespace std;
//使用宽字符,我猜是为了适应那些要使用宽字符的国家
int main()
{
    auto path = Plug::GetCurrentPath();//返回std::wstring宽字符
    std::wstring line;
    path += L"hello.txt";//L表示宽字符
    std::wifstream wif(path);
    wif >> line;
    auto str = Plug::wcstombs(line);//由std::wstring转换std::string
    std::cout << str.c_str();
    wif.close();
    system("pause");
}

流继承关系图:

posted @ 2014-05-23 23:30  zzyoucan  阅读(2249)  评论(0编辑  收藏  举报