zoukankan      html  css  js  c++  java
  • 以宽字符形式读整个文件的内容(wifstream的使用)

    // TestShlwAPI.cpp : 定义控制台应用程序的入口点。
    //

    #include "stdafx.h"


    #include <iostream>
    using std::wcout;
    using std::endl;

    #include <string>
    using std::wstring;

    #include <fstream>
    using std::wifstream;


    int _tmain(int argc, _TCHAR* argv[])
    {
      
        //main.cpp:

    //读我自己

        wifstream fin("TestShlwAPI.cpp");
        wstring str;
        wchar_t wcharArr[1024];
        while (!fin.eof())
        {
            /*fin >> str;
            wcout << str << endl;*/
            fin.getline(wcharArr,1024);
            wcout << wcharArr << endl;
        }

        
        
        while (!fin.eof())
        {
            fin >> wcharArr;
            wcout << wcharArr << endl;
        }
        
        
        fin.seekg(-1);//设置读的位置影响fin.rdbuf(),不影响fin.eof()
        if (!fin.bad())
        {
            // Dump the contents of the file to cout.
            wcout << fin.rdbuf();
            fin.close();
        }

        fin.close();
        system("pause");
        return 0;
    }

  • 相关阅读:
    RHEL6 建立DVD repo
    stl之std::remove_copy
    分鱼问题
    Nutch的日志系统
    log4j配置文件及nutch中的日志配置
    slf4j教程
    Java中的日期操作
    Avro基础
    【JAVA编码专题】总结
    【JAVA编码专题】深入分析 Java 中的中文编码问题
  • 原文地址:https://www.cnblogs.com/shenchao/p/3193368.html
Copyright © 2011-2022 走看看