#include <set>
#include <stdio.h>
#include <iostream>
#include <istream>
#include <fstream>
#include <iterator>
using namespace std; int main()
{
ifstream inputFile("1.txt");
string fileData((istreambuf_iterator<char>(inputFile)),
istreambuf_iterator<char>());
cout<<fileData<<endl;
return ;
}

istreambuf_iterator的更多相关文章

  1. 使用 istreambuf_iterator 读取文件内容,赋值给 std::string

    需要一个一个字符输入时考虑使用istreambuf_iterator 假设我们要把一个文本文件拷贝到一个字符串对象中.似乎可以用一种很有道理的方法完成: ifstream inputFile(&quo ...

  2. 《条目二十九:对于逐个字符的输入请考虑istreambuf_iterator》

    <条目二十九:对于逐个字符的输入请考虑istreambuf_iterator> 1.使用: ifstream inputfile("xxxx"); string fil ...

  3. 让C++程序打印自身源码

    本人原创文章,欢迎阅读,禁止转载. 这绝对是惊艳到让你眼前一亮(为了简洁,故意没考虑资源问题和编译警告). #include <iostream> #include <fstream ...

  4. C.C++把整个文件内容读进一个buffer中

    原创文章,未经本人允许禁止转载. //C方式, 调用的函数繁多 //fopen,fseek,ftell,fseek,malloc,fread,fclose,free. void foo() { FIL ...

  5. iterator 及 迭代器模式(转发)

    Iterator definitions An iterator is any object that, pointing to some element in a range of elements ...

  6. 谷歌开源项目Google Preview Image Extractor(PIEX) (附上完整demo代码)

    前天偶然看到谷歌开源项目中有一个近乎无人问津的项目Google Preview Image Extractor(PIEX) . 项目地址: https://github.com/google/piex ...

  7. c++模板库(简介)

    目 录 STL 简介 ......................................................................................... ...

  8. [c++][语言语法]stringstream iostream ifstream

    c++中ifstream一次读取整个文件 读取至char*的情况 std::ifstream t; int length; t.open("file.txt"); // open ...

  9. Effective STL 中文版(大全)

    Effective STL 中文版(大全) 作者:winter 候捷说,对于STL,程序员有三个境界,开始是使用STL,然后是理解STL,最后是补充STL.Effective STL是一本非常好的书, ...

随机推荐

  1. selenium打不开chrome

    selenium打不开chrome,出现下面的报错 requests.exceptions.ChunkedEncodingError: ("Connection broken: Connec ...

  2. java中文转Unicode

    public String cnToUnicode(String cn) { char[] chars = cn.toCharArray(); String returnStr = "&qu ...

  3. maven的相关命令

    maven的相关命令 mvn archetype:create :创建 Maven 项目 mvn compile :编译源代码(编译到target文件夹中) mvn test-compile :编译测 ...

  4. 菩提树下的杨过.Net 的《hadoop 2.6全分布安装》补充版

    对菩提树下的杨过.Net的这篇博客<hadoop 2.6全分布安装>,我真是佩服的五体投地,我第一次见过教程能写的这么言简意赅,但是又能比较准确表述每一步做法的,这篇博客主要就是在他的基础 ...

  5. GIT如何使用:大杀器!所有常用指令整理

    1 pwd 显示当前目录2 mkdir 创建目录 cd 进入文件3 git init 变成Git可以管理的仓库(千万不要修改目录下的.git隐藏文件夹)4 ls -ah 可以把.git文件显示出来5 ...

  6. Sybase:循环调用存储过程

    Sybase:循环调用存储过程 一.日期循环 declare @c_count int declare @rq int --获取两个日期之间的天数 ,getdate()) begin ,),),),) ...

  7. 常用iptables命令

    1.不让某个ip访问本机的80端口: iptables -t filter -I INPUT -p tcp -s 192.168.222.163 --dport 80 -j DROP 2.实现把访问 ...

  8. 2 Powershell与Cmd以及Unix/Linux Shell

    上篇文章我说道,windows为了改变用户对其console界面的诟病,于是就从windows   vista开始,计划要改变这种局面,于是就有 了Powershell的出现. 1.兼容shell命令 ...

  9. [POI2009]Lyz

    Description 初始时滑冰俱乐部有1到n号的溜冰鞋各k双.已知x号脚的人可以穿x到x+d的溜冰鞋. 有m次操作,每次包含两个数ri,xi代表来了xi个ri号脚的人.xi为负,则代表走了这么多人 ...

  10. spark学习14(spark local模式运行spark程序的报错)

    报错1 java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. 解 ...