一次读取文件中所有内容

简介:

http://blog.csdn.net/banzhiyu/archive/2007/07/26/1708438.aspx

一次读取文件中所有内容 

#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;

int  main()
{
string str;
ifstream ifile("test.txt");

ostringstream tmp;
tmp<<ifile.rdbuf();  //
str = tmp.str();
cout<<str<<endl;

system("pause");
return 0;
}

目录
相关文章
|
1月前
|
Linux Windows
写入文件
写入文件。
14 2
|
4月前
|
XML C# 数据格式
C#读取写入文件的三种方式
最近对文件的操作比较频繁。这里记录一下常用的几种文件读写的方式。 我这里使用窗体来做测试,例子在文末,可下载。
50 0
|
8月前
|
Shell 开发工具
读取文件
读取文件
28 3
|
8月前
|
Python
Python 文件操作(创建、读取、追加、图片视频读取)
Python 文件操作(创建、读取、追加、图片视频读取)
89 0
C++ 中 ifstream读取txt文件内容
C++ 中 ifstream读取txt文件内容
1190 0
C++ 中 ifstream读取txt文件内容
|
移动开发 C++ Windows
C++读取文件
C++读取文件
读取文件的多种方式
读取文件的多种方式和
C#编程-35:写入读取文本文件
C#编程-35:写入读取文本文件