以宽字符形式读整个文件的内容(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;
}
以宽字符形式读整个文件的内容(wifstream的使用)的更多相关文章
- day08(字符编码,字符与字节,文件操作)
一,复习 ''' 类型转换 1.数字类型:int() | bool() | float() 2.str与int: int('10') | int('-10') | int('0') | float(' ...
- py库: xlwt 、xlrd (写读EXCEL文件)
写EXCEL文件 # -*- coding: utf-8 -*- import xlwt book = xlwt.Workbook(encoding = "utf-8", styl ...
- 73.fseek与宽字符读取文件
fseek //文件路径 ] = "1.txt"; //FILE *pf = fopen(path, "a+");//尾部添加,文件指针在尾部 //FILE * ...
- volatile,可变参数,memset,内联函数,宽字符窄字符,国际化,条件编译,预处理命令,define中##和#的区别,文件缓冲,位域
1.volatile: 要求参数修改每次都从内存中的读取.这种情况要比普通运行的变量需要的时间长. 当设置了成按照C99标准运行之后,使用volatile变量之后的程序运行的时间将比register的 ...
- C语言以字符形式读写文件
一.字符读取函数 fgetc (一).函数介绍 fgetc 是 file get char 的缩写,意思是从指定的文件中读取一个字符.函数原型为: int fgetc(FILE* fp) fp 为文件 ...
- matlab文件操作及读txt文件(fopen,fseek,fread,fclose)
文件操作是一种重要的输入输出方式,即从数据文件读取数据或将结果写入数据文件.MATLAB提供了一系列低层输入输出函数,专门用于文件操作. 1.文件的打开与关闭 1)打开文件 在读写文件之前,必须先用f ...
- MATLAB文件操作及读txt文件
转自:http://blog.csdn.net/vblittleboy/article/details/8049748 文件操作是一种重要的输入输出方式,即从数据文件读取数据或将结果写入数据文件.MA ...
- C语言小程序——推箱子(窄字符和宽字符)
C语言小程序——推箱子(窄字符Version) 推箱子.c #include <stdio.h> #include <conio.h> #include <stdlib. ...
- 彻底解密C++宽字符(二)
彻底解密C++宽字符(二) 转:http://club.topsage.com/thread-2227977-1-1.html 4.利用codecvt和use_facet转换 locale和facet ...
随机推荐
- 关于DLL文件和EXE文件不在同一目录下的设置【转】
https://www.cnblogs.com/chaosimple/archive/2012/08/13/2636181.html 关于DLL文件和EXE文件不在同一目录下的设置 在开发程序结束后, ...
- Trapping Rain Water leetcode java
题目: Given n non-negative integers representing an elevation map where the width of each bar is 1, co ...
- hdu 4491 Windmill Animation
A windmill animation works as follows: A two-dimensional set of points, no three of which lie on a l ...
- Ionic 4 and the Lifecycle Hooks
原文: https://medium.com/@paulstelzer/ionic-4-and-the-lifecycle-hooks-4fe9eabb2864 ------------------- ...
- Sql server management studio: cannot find one or more components
Install VS2010 SHELL 独立组件 https://www.microsoft.com/en-US/download/details.aspx?id=1366 运行安装程序,rep ...
- IDEA报错Target level '1.6' is incompatible with source level '1.7'
解决IDEA 编译级别 Error:java: Target level '1.6' is incompatible with source level '1.7'. A target level ' ...
- 【Nodejs】“快算24”扑克牌游戏算法 1.01
考虑到1.00版本需要改源码变更四个数字,这版修改了一下变成控制台输入了. 先把两个数四则运算得到结果想清楚就是C2代码,三个数就是C3,四个数就是C4.简单的代码简单,却是复杂的基础:复杂的脱胎于简 ...
- 使用Python脚本批量裁切栅格
对栅格的裁切,我们通常使用裁切(数据管理-栅格-栅格处理)或按掩膜提取(空间分析-提取分析)来裁切,裁切的矢量要素通常是一个要素图层或Shape文件.如果要进行批量处理,可以使用ToolBox中的批量 ...
- eclipse 代码上传github 笔记
第一步 先share project 如图所示 第二步 如果所示 第三步 点击 下面的create 然后点击完成 第四步提交 第五步: 第六步:
- 网站中超链接方式直接添加QQ好友
使用情景: 在图中点击图片,会弹出添加qq好友的窗口进行好友添加. 链接如下: tencent://AddContact/?fromId=45&fromSubId=1&subcmd=a ...