以宽字符形式读整个文件的内容(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 ...
随机推荐
- Binary Tree Preorder Traversal leetcode java
题目: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given bina ...
- AS 代码模板 文件模板 Templates MD
修改 File and Code Templates Settings –> Editor –>[File and Code Templates] 或者在右键new时选择子菜单[Edite ...
- JavaScript操作XML (一)
JavaScript操作XML是通过XML DOM来完成的.那么什么是XML DOM呢?XML DOM 是: 用于 XML 的标准对象模型 用于 XML 的标准编程接口 中立于平台和语言 W3C 的标 ...
- [Algorithm] Given the root to a binary tree, return the deepest node
By given a binary tree, and a root node, find the deepest node of this tree. We have way to create n ...
- [Angular-Scaled web] 1. Architecture and file structure
We build a project according to its features or based on simple MVC structure. Put all controller in ...
- Linux清理磁盘空间
1.首先确定是否是磁盘满了 命令: df -h 参数说明: -a:列出所有的文件系统,包括系统特有的/proc等文件系统 -k:以KB的容量显示各文件系统 -m:以MB的容量显示各文件系统 -h: ...
- Jquery 应用积累
1.控制div显隐 $("#id").show()表示display:block, $("#id").hide()表示display:none; $(" ...
- 使用socket BPF/Linux内核工程导论——网络:Filter(LSF、BPF、eBPF)
使用socket BPF linux 下的 包过滤器 BPF Linux内核工程导论——网络:Filter(LSF.BPF.eBPF) 注意(文中描述的内容): 此外,这段BPF代码还存在的一个问题是 ...
- 嵌套循环连接(nested loops join)原理
嵌套循环连接(nested loops join) 访问次数:驱动表返回几条,被驱动表访问多少次. 驱动表是否有顺序:有. 是否要排序:否. 应用场景: 1.关联中有一个表比较小: 2.被关联 ...
- git命令 add -a和add .和add -u 的区别
总结: git add -a 所有的更改操作--新建,更改,删除: git add . 只包括 新建 ,修改操作:无删除: git add -u 只包括修改,删除操作,无新建: 示例: git ini ...